Moving app to production mode in Symfony 2

最后都变了- 提交于 2019-11-27 17:06:56

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.

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

The Symfony CookBook has now a few recipes about deployment covering:

Symfony2 How to Master and Create new Environments http://symfony.com/doc/current/cookbook/configuration/environments.html

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!