Moving app to production mode in Symfony 2 Moving app to production mode in Symfony 2 symfony symfony

Moving app to production mode in Symfony 2


Couple more things to consider:

php app/console cache:clear --env=prod --no-debugphp app/console assets:install web_directoryphp 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.


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


Basic configuration information can be found here:http://symfony.com/doc/current/cookbook/configuration/web_server_configuration.html

One important spot where many people stumble is asset management. When accessing the app via the app.dev front controller (see fist link), it may be necessary to dump the assets first. Read all about it here:http://symfony.com/doc/current/cookbook/assetic/asset_management.html#cookbook-assetic-dumping