Moving app to production mode in Symfony 2
Solution 1
Couple more things to consider:
php app/console cache:clear --env=prod --no-debug
php app/console assets:install web_directory
php app/console assetic:dump web_directory
You might also run into permission issues with the cache directory. I would actually first make sure everything works in development mode on the server before switching to production mode. And if all you get is blank screens in production mode then set debug to true. And of course know how to check your error logs.
Solution 2
Moving Symfony2 to production means :
access the application through : app.php/
Test dev bundles won't be loaded since there is a condition into the AppKernel.php when you use app.php. If you want to unload bundle that should be used only in dev, you can place them into the this section (in appKernel.php)
if (in_array($this->getEnvironment(), array('dev', 'test'))) {
$bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
$bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle();
$bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle();
$bundles[] = new Sf2gen\Bundle\GeneratorBundle\Sf2genGeneratorBundle();
}
You also need to make some server tuning by désactivating xdebug and adding eacclerator (or someting else for caching performance)
I also advice to rename app_dev.php to disactivate dev mode
Noor
Love programming, designing system, their architectures, fond of client side web programming using javascript frameworks such as angularjs, emberjs or other like GWT
Updated on March 26, 2020Comments
-
Noor over 4 years
Can someone help me to move my Symfony 2 application into production mode?
Currently, the application is running properly in
/app_dev.php
.I'm googling, but I'm not finding a definite guide for deployment in Symfony 2.
-
Noor over 12 yearscan you be more explicit about how to setup the production mode
-
Cerad over 12 yearsThe Symfony logs are in app/logs. The web server depends on the server and how it is configured so can't really help there.
-
Noor over 12 yearsyou answer was THE answer, thanks, by the way, all those who'll use this answer, everytime u change something in your scripts, do this, php app/console cache:clear --env=prod --no-debug, also sometime u need to change permission, so do a chown !!
-
rjmunro about 11 yearsThis answer isn't standalone. Can you include the relevant bits of the other answer rather than start with "Couple more things"? E.g. "Configure rewrite rules to use
app.php
, notapp_dev.php
, removeapp_dev.php
" -
SirDerpington about 10 yearsShouldn't you also run the
php app/console cache:warmup --env=prod
command?