Search code examples
phpsymfonysymfony4

Symfony 4, get .env parameter from a controller, is it possible and how?


From symfony 4, I want create a global parameter and get the value of this parameter from a controller.

This parameter is the path of an another app in the server. So, I thinked add the paramerter in the .env file. But how can I get the value of this parameter from a controller?


Solution

  • Did you try with:

    $this->getParameter('your parameter');
    

    Edit:

    This may help you -> https://symfony.com/doc/current/components/dotenv.html