Description
Hello,
I started using the stable version of Symfony 4.2, but it's not clear to me how to use $this->container
, since all the documentation of 4.2 used it, but I haven't really been able to use it.
Example:
//services.yml
app.theme:
class: App\Service\Theme
public: true
autowire: true
Error:
Service "app.theme" not found: even though it exists in the app's container, the container inside "App\Controller\Front\BlogController" is a smaller service locator that only knows about the "doctrine", "form.factory", "http_kernel", "parameter_bag", "request_stack", "router", "security.authorization_checker", "security.csrf.token_manager", "security.token_storage", "serializer", "session", "templating" and "twig" services.Try using dependency injection instead.
That combination together with many other combinations, has not worked for me, so not being what happens in the Container
, I have followed everything from documentation, but there are many more that refer to the Container
, but not if your intention is to remove it completely.
So, my question is if I can make use of the container or what is really happening, please hope you can help me understand.
Reference:
https://symfony.com/doc/current/service_container.html#public-versus-private-services
https://symfony.com/doc/master/service_container/alias_private.html#aliasing
https://symfony.com/doc/master/service_container/autowiring.html#an-autowiring-example
https://symfony.com/doc/current/service_container/calls.html
Well, almost everything related to the container is not clear.