【发布时间】:2012-03-04 17:57:34
【问题描述】:
有人可以帮我将 Symfony 2 应用程序转移到生产模式吗?
目前,应用程序在/app_dev.php中运行正常。
我在谷歌上搜索,但没有找到在 Symfony 2 中部署的明确指南。
【问题讨论】:
标签: deployment symfony production-environment
有人可以帮我将 Symfony 2 应用程序转移到生产模式吗?
目前,应用程序在/app_dev.php中运行正常。
我在谷歌上搜索,但没有找到在 Symfony 2 中部署的明确指南。
【问题讨论】:
标签: deployment symfony production-environment
还有更多需要考虑的事情:
php app/console cache:clear --env=prod --no-debug
php app/console assets:install web_directory
php app/console assetic:dump web_directory
您还可能会遇到缓存目录的权限问题。在切换到生产模式之前,我实际上会首先确保一切都在服务器上的开发模式下工作。如果你得到的只是生产模式下的空白屏幕,那么将 debug 设置为 true。当然知道如何检查你的错误日志。
【讨论】:
app.php,而不是app_dev.php,删除app_dev.php"
php app/console cache:warmup --env=prod 命令吗?
将 Symfony2 移至生产意味着:
通过:app.php/访问应用程序
不会加载测试开发包,因为在您使用 app.php 时,AppKernel.php 中有一个条件。如果你想卸载应该只在 dev 中使用的包,你可以将它们放在这个部分(在 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();
}
您还需要通过停用 xdebug 和添加 eacclerator(或其他一些缓存性能)来调整服务器
我还建议重命名 app_dev.php 以禁用开发模式
【讨论】:
基本配置信息可以在这里找到: http://symfony.com/doc/current/cookbook/configuration/web_server_configuration.html
许多人绊倒的一个重要方面是资产管理。通过 app.dev 前端控制器访问应用程序时(参见第一个链接),可能需要先转储资产。在这里阅读所有相关信息: http://symfony.com/doc/current/cookbook/assetic/asset_management.html#cookbook-assetic-dumping
【讨论】:
Symfony CookBook 现在有几个 recipes about deployment 覆盖:
【讨论】:
Symfony2 如何掌握和创造新环境 http://symfony.com/doc/current/cookbook/configuration/environments.html
【讨论】: