Replies: 2 comments 3 replies
-
Hi ! Welcome to the Symfony world ! You are right when you say "there's only one service container object for the whole Symfony application". But in fact, you can meet some "scoped" containers, which are the service locators. For example, if you inspect the code fomr the AbstractController from Symfony, you can see a You can read the documentation about the service locators here https://symfony.com/doc/current/service_container/service_subscribers_locators.html#defining-a-service-subscriber Enjoy ! |
Beta Was this translation helpful? Give feedback.
-
Yes, there is only one DI container that is owned by Kernel class and is instantiated when php script is being executed. |
Beta Was this translation helpful? Give feedback.
-
I'm learning about Symfony, so about services and containers. I understand that services are objects, created and maintained by the so-called service container, which we can inject as parameters to our controllers. For example,
LoggerInterface
orEntityManagerInterfacer
are services. What I am not sure about, after having read about the topic, is if there's only one service container object for the whole Symfony application or if there are multiple ones. If multiple ones, why is that?Beta Was this translation helpful? Give feedback.
All reactions