Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scalar constructor / property injection etc. #44

Closed
elbakerino opened this issue Apr 7, 2020 · 1 comment
Closed

scalar constructor / property injection etc. #44

elbakerino opened this issue Apr 7, 2020 · 1 comment

Comments

@elbakerino
Copy link

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
Copy link
Author

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'),
        ],
    ],
];

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant