Symfony 4 how to enable prod mode?
You have to ensure that the environment variable APP_ENV
is set correctly in your production environment. The documentation tells you how to do this for various web servers. For example, in your Apache-configuration you have to use SetEnv
. This could look something like this:
DocumentRoot /var/www/project/public<Directory /var/www/project/public> AllowOverride None Order Allow,Deny Allow from All <IfModule mod_rewrite.c> Options -MultiViews RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.php [QSA,L] </IfModule></Directory>SetEnv APP_ENV prodSetEnv APP_DEBUG 0...
A similar configuration for nginx would use fastcgi_param
and would look somewhat like this:
location ~ ^/index\.php(/|$) { fastcgi_pass unix:/var/run/php7.1-fpm.sock; fastcgi_split_path_info ^(.+\.php)(/.*)$; include fastcgi_params; fastcgi_param APP_ENV prod; fastcgi_param APP_DEBUG 0;}
The doc page is a bit mean, because the respective bits are commented out.
If you want to simulate the production environment with the built-in webserver you can do it like this:
APP_ENV=prod APP_DEBUG=0 bin/console server:run
This requires the server-pack to be installed using composer and of course you can also set the command option --env
as well, for the same effect.
And also make sure that you have checked .env
and .env.local
file too.
# prod config of .env or/and .env.localAPP_ENV=prodAPP_DEBUG=0