symplify/autowire-array-parameter
Automatically inject array parameters into PHP services with minimal configuration. Symplify Autowire Array Parameter resolves array constructor arguments from container config, reducing boilerplate and making service wiring cleaner in Symfony/Laravel-style DI setups.
This package is archived and incompatible with Laravel’s DI container entirely. Laravel does not support Symfony’s compiler passes, !autowire_array_parameter syntax, or its DI extension points—so no Laravel developer should attempt to use it. If you're seeing this package referenced in a Laravel context, it indicates a misconfiguration or misunderstanding of framework boundaries. For Laravel, rely on native features like #[Autowire] (PHP 8+), taggedautowiring via #[Tagged] (Laravel 9+), or explicit binding in service providers.
In Laravel, handle array parameter autowiring natively:
// Register tagged services
$this->app->tag([FooHandler::class, BarHandler::class], 'handler');
// Inject via autowiring
class HandlerAggregator
{
public function __construct(
#[Tagged('handler')] iterable $handlers
) {}
}
// App\Providers\AppServiceProvider@register
$this->app->bind('App\HandlerAggregator', function ($app) {
return new HandlerAggregator(
$app->tagged('handler')
);
});
// config/handlers.php
return [
'App\Handler\LoggerHandler',
'App\Handler\MetricsHandler',
];
// Inject via constructor
class MyService
{
public function __construct(
protected array $handlers = []
) {
$this->handlers = config('handlers');
}
}
🚫 Do not mix Symfony-specific packages into Laravel apps — this causes silent failures, container resolution errors, and hidden coupling to outdated patterns.
⚠️ Avoid hardcoded service locator patterns: Laravel’s DI container does not support service locators like Symfony’s service_locator references. Instead, inject cleanly with type hints and Tagged attributes.
🔍 Debug DI issues with php artisan tinker: Use app()->make(MyService::class) to test instantiation and inspect failing dependencies.
🧠 Think in terms of service providers, not compiler passes: Laravel is built around manual registration, not reflection-based compiler passes. If you’re writing compiler passes for Laravel, you’re likely misusing the framework.
✅ Prefer Laravel’s built-in tools: #[Tagged], app()->tagged(), config-based arrays, and interface-to-concrete bindings cover all real-world array-injection use cases—no external packages needed.
How can I help you explore Laravel packages today?