tomphp / container-configurator

Configure your application and the Dependency Injection Container (DIC) via config arrays or config files.
MIT License
20 stars 3 forks source link

Allow container injection via configuration #62

Closed tomphp closed 8 years ago

tomphp commented 8 years ago

On the rare occasion, you might want to inject the container into a service. It would be a helpful feature to be able to do with via the configuration. Maybe something like:

$appConfig = [
    'di' => [
        'services' => [
            MyService::class => [
                'arguments' => [Configurator::CONTAINER],
            ],
        ],
    ],
];

It would also be useful to have the container available in ServiceFactories. A common approach to this would be to have a ContainerAware interface and trait or abstract class.

Pros:

Cons: