I'm using Symfony 3 and I'm looking at how to inject services into my controllers via the constructor. I don't want to register each controller as a service.
Diving into the code I have overridden the default ControllerResolver's instantiateController method with the following:
protected function instantiateController($classname) {
return $this->container->get($classname);
}
Note: I have passed in the container within the constructor and I am using Symfony's dependency injection component.
However this throws the error:
You have requested a non-existent service "controllers\hellocontroller"
I thought auto resolving was built into the latest version of Symfony DI. I was wondering if anyone could show me what I am doing wrong.
Thanks