Answer the question
In order to leave comments, you need to log in
How to implement such a mechanism for the service container?
Good day everyone.
The situation is this:
1. There is a certain service container. $conatiner;
2. We put some class in it, for example phpMailer
$conatiner->set('mailer',function(){
return new phpMailer();
})
$mailer = $conatiner->get('mailer');
// тут задаём необходимые параметры класса phpMailer
$mailer->send();
$someMailer = new MyMailerClass(new phpMailer());
Answer the question
In order to leave comments, you need to log in
symfony.com/doc/current/components/dependency_inje...
Pass the class name as a string.
https://stackoverflow.com/questions/4578335/creati...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question