Moving app to production mode in Symfony 2

微笑、不失礼 提交于 2019-11-26 22:31:17

问题


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.


回答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.




回答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




回答3:


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




回答4:


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

  • standard linux-based web-server: How to Deploy a Symfony2 Application,
  • Microsoft Azure Website Cloud: Deploying to Microsoft Azure Website Cloud,
  • Heroku Cloud: Deploying to Heroku Cloud.



回答5:


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



来源:https://stackoverflow.com/questions/9258715/moving-app-to-production-mode-in-symfony-2

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