When using dev mode with a Symfony2.x application, one usually works in locale. Hence, such function does not works as expected (for instance, try to get th
Since you want to know if you are in dev mode (not necessarilly the environment named "dev"), you can retrieve the kernel from the service container and check the isDebug
method return:
$kernel = $this->get('kernel');
$devMode = $kernel->isDebug();
As noted in the documentation (emphasis is mine),
Important, but unrelated to the topic of environments is the
true
orfalse
argument as the second argument to theAppKernel
constructor. This specifies if the application should run in "debug mode". Regardless of the environment, a Symfony application can be run with debug mode set to true or false. This affects many things in the application, such as displaying stacktraces on error pages or if cache files are dynamically rebuilt on each request. Though not a requirement, debug mode is generally set to true for the dev and test environments and false for the prod environment.Internally, the value of the debug mode becomes the kernel.debug parameter used inside the service container.