tbachert/spi
Composer-powered Service Provider Interface loader inspired by Java’s ServiceLoader. Register providers via composer.json extra.spi or PHP, optionally precompile registrations from autoload files, and load implementations at runtime. Used by OpenTelemetry PHP SDK autoconfiguration.
Architecture fit: Laravel's built-in service container and ServiceProvider system already fulfills SPI-like functionality for dependency injection. This package introduces an unnecessary duplicate layer that conflicts with Laravel's core patterns unless explicitly required by third-party dependencies (e.g., OpenTelemetry SDK). It creates conceptual confusion between two service registration systems in the same application.
Integration feasibility: Highly constrained to niche scenarios like OpenTelemetry integration. Requires explicit Composer plugin trust configuration (allow-plugins.tbachert/spi true), adding operational complexity with minimal benefit for standard Laravel applications. No native compatibility with Laravel's DI container.
Technical risk: Low adoption metrics (9 stars, 0 dependents) indicate minimal community validation. Composer plugin execution introduces security surface area. Constructor requirement (public zero-arg) conflicts with Laravel's constructor-injection DI patterns. Runtime overhead without precompilation.
Key questions: Is there a hard dependency requiring this package (e.g., OpenTelemetry SDK)? How will it coexist with Laravel's existing service container? What's the maintenance commitment for the package given its current maturity? Are there alternative solutions within Laravel's ecosystem (e.g., custom container extensions)?
Stack fit: Only suitable for projects with explicit SPI requirements (e.g., OpenTelemetry SDK autoconfiguration). Not recommended for general Laravel applications where Laravel's native service container provides superior DI capabilities. Should be avoided for new projects without third-party dependency mandates.
Migration path: If integrating with OpenTelemetry, follow SDK documentation for SPI registration. For existing Laravel apps, avoid using this package entirely—leverage Laravel's ServiceProvider system instead. If absolutely required, register providers via composer.json extra.spi or ServiceLoader::register(), but enforce precompilation (extra.spi-config.autoload-files: true) for production.
Compatibility: Works with Composer but requires PHP ≥7.4. Conflicts with Laravel's constructor-based DI (SPI mandates zero-arg constructors). Must ensure no overlap between SPI registrations and Laravel's service container to prevent duplicate instances. Not compatible with non-Composer environments.
Sequencing: 1) Validate necessity (e.g., OpenTelemetry dependency exists). 2) Enable Composer plugin trust only if required. 3) Register providers declaratively (via extra.spi) for stability. 4) Precompile service maps during build process. 5) Isolate SPI usage strictly to third-party
How can I help you explore Laravel packages today?