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
If you are using .env
to store your environment variables, you can access them in any controller by simply using $_ENV['name-of-variable']
For a default installation, there is a $_ENV["APP_ENV"]
variable available, which will tell you if you are in dev mode or not.
Use print_r($_ENV);
to see all the available environment variables.
[ps - This also works for Symfony 3.4]
Reference - https://symfony.com/doc/4.3/components/dotenv.html