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.
Install the package with composer require tbachert/spi. This adds a Composer plugin used primarily by OpenTelemetry PHP SDK for dynamic extension loading. If you’re not leveraging OpenTelemetry’s autoconfiguration (e.g., you configure exporters/tracers manually), you can safely disable the plugin afterward via composer config allow-plugins.tbachert/spi false. Your first practical step is registering implementations—via composer config --json --merge extra.spi 'Namespace\\Service' '["Namespace\\Implementation"]' for declarative setup, or ServiceLoader::register(...) in bootstrap code.
extra.spi in composer.json to list implementations—ideal for libraries expecting consumers to register their own providers (e.g., custom exporters). Register at install time: composer config --json --merge extra.spi."App\\Contracts\\MetricExporter" '["App\\Metrics\\PrometheusExporter"]'.ServiceLoader::register(...) in bootstrap/app.php or service providers for dynamic decisions (e.g., load DebugExporter only in local environment).extra.spi-config.autoload-files: true in composer.json to convert register() calls into a static classmap, eliminating Composer plugin overhead at runtime—crucial for production.ServiceLoader::load() + getIterator() to catch ServiceConfigurationError when providers fail to instantiate (e.g., missing dependencies), allowing fallback behavior.ServiceLoader::register()-using files are removed from autoload.files after precompilation. Set extra.spi-config.prune-autoload-files: false if those files contain critical side-effect bootstrapping (e.g., environment setup).Do you trust "tbachert/spi"). For non-OpenTelemetry apps, disable the plugin after installation (allow-plugins.tbachert/spi false) to reduce runtime attack surface.composer install -vvv to see plugin logs, and verify extra.spi entries match exact FQCNs. Double-check class existence and constructor signatures.$provider->configure($this->app) in a Laravel ServiceProvider) or use reflection-based wiring post-load.How can I help you explore Laravel packages today?