Symfony2 WebProfiler如何显示生产环境?

5

在开发环境中,使用jQuery系统非常缓慢,但是在生产环境中运行得很好。能否将WebProfiler应用于生产环境?谢谢。

1个回答

16

将以下内容添加到routing.yml中:

_wdt:
    resource: "@WebProfilerBundle/Resources/config/routing/wdt.xml"
    prefix:   /_wdt

_profiler:
    resource: "@WebProfilerBundle/Resources/config/routing/profiler.xml"
    prefix:   /_profiler
将此添加到config_prod.yml中:
web_profiler:
    toolbar: true

AppKernel.php 文件中进行修改:

从此语句中删除 $bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle()

if (in_array($this->getEnvironment(), array('dev', 'test'))) {
    // ...
}

将此添加到if语句外的bundles数组中:

new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle()
app.php 中将 debug 设为 true。
$kernel = new AppKernel('prod', true);

config_prod.yml 中添加:

framework:
    profiler:
        only_exceptions: false

应该可以解决问题。

在进行代码更改后,不要忘记执行此操作:

$ php ./app/console cache:clear --env=prod --no-debug

3
那么,你如何调用性能分析器?它会像那样显示吗?因为那对我没有起作用。 - Aysennoussi
两年后你可能已经找到了答案,但为了记录:进入你的url/_profiler。 - Ninj
不要忘记:
  • 在 app.php 中将 debug 设置为 true: $kernel = new AppKernel('prod', true);
  • 在 config_prod.yml 中添加: framework: profiler: only_exceptions: false
- Ajsti.pl - Maciej Szewczyk

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接