Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Moving app to production mode in Symfony 2

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.

like image 330
Noor Avatar asked Feb 13 '12 10:02

Noor


2 Answers

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.

like image 97
Cerad Avatar answered Sep 20 '22 23:09

Cerad


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

like image 11
Chopchop Avatar answered Sep 20 '22 23:09

Chopchop