Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Autowire Array Parameter Laravel Package

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.

View on GitHub
Deep Wiki
Context7

Getting Started

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.

Implementation Patterns

In Laravel, handle array parameter autowiring natively:

  • Constructor injection with tagged services (Laravel 9+):
    // Register tagged services
    $this->app->tag([FooHandler::class, BarHandler::class], 'handler');
    
    // Inject via autowiring
    class HandlerAggregator
    {
        public function __construct(
            #[Tagged('handler')] iterable $handlers
        ) {}
    }
    
  • Explicit binding in a service provider for older Laravel versions:
    // App\Providers\AppServiceProvider@register
    $this->app->bind('App\HandlerAggregator', function ($app) {
        return new HandlerAggregator(
            $app->tagged('handler')
        );
    });
    
  • Dynamic configuration via config files:
    // 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');
        }
    }
    

Gotchas and Tips

🚫 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.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport