Symfony 4 front controller

3.4k Views Asked by At

Symfony 4 resigns on app.php and app_dev.php front controllers. Now it will be only one index.php. We can manipulate dev and prod environment in .env file. Please tell me is it only one way to change environment? I can't do that from the browser (as it was previous app and app_dev files)?

1

There are 1 best solutions below

0
On BEST ANSWER

You control what is in the index.php file, so you can arrange to include a different env file according to the rules that you decide.

For example, you can set a variable in the Apache vhost or Nginx FastCgi configuration, based on the URL you are visiting from - such as APP_ENV=/home/myname/app-name/dev.env or on a live server: APP_ENV=/etc/app-name.prod.env set as you like, or you could list both of them in the index.php and choose which one from there - although taking the option out of the code and setting it in a server configuration would probably be safer in the long term.