phpsymfonysymfony-http-kernel

How to retrieve Symfony 3's Kernel instance in an application?


I would like to access Symfony 3's Kernel.getEnvironment() in a service implementing the ContainerAwareTrait.

I am wondering whether I should implement an instance of the Kernel object or whether one is already created by the application itself. If so, how can I retrieve the instance?

My application is a clone of the Symfony 3 demo application.


Solution

  • Couldn't you just inject %kernel.environment% into your service?