elie29 / zend-di-config

PSR-11 PHP-DI container configurator for Laminas, Mezzio, ZF, Expressive applications or any framework that needs a PSR-11 container
MIT License
19 stars 4 forks source link

scalar constructor / property injection etc. #44

Closed elbakerino closed 4 years ago

elbakerino commented 4 years ago

Used PHP-DI and liked the way of configuring services, e.g. constructor injection for scalar values.

return [
    'Logger' => DI\create()
        ->constructor('/tmp/app.log'),
];

How can stuff like this be done when using this config lib?

elbakerino commented 4 years ago

Okay... just using it in services works, actual problem was using it in autowires.

return [
    'dependencies' => [
        'services' => [
            Psr\Log\LoggerInterface::class => DI\autowire(Monolog\Logger::class)
                ->constructor('default')
                ->method('pushHandler', DI\get(Monolog\Handler\StreamHandler::class)),
            Monolog\Handler\StreamHandler::class => DI\autowire()
                ->constructor('php://stdout'),
        ],
    ],
];