如何禁用Symfony 2 Profiler栏?

Rud*_*die 48 debugging profiler symfony

它没有添加任何东西,它使页面变慢,我希望它消失.不要问.关于网站上的分析器,应用程序配置中没有任何内容.

Rud*_*die 99

此设置位于app/config/config_dev.yml:

web_profiler:
    toolbar: true
    intercept_redirects: false
Run Code Online (Sandbox Code Playgroud)

  • 作为对未来开发者的评论.如果您想在开发模式下"禁用"REDIRECTS并且能够调试POST等,那么这个答案是最好的.只是intercept_redirects:true它会起作用:D (2认同)

Bes*_*nik 87

附加:如果要在控制器中为特殊操作禁用它而不是使用它:

if ($this->container->has('profiler'))
{
    $this->container->get('profiler')->disable();
}
Run Code Online (Sandbox Code Playgroud)

  • 要仍然在/ _profiler中输出但没有工具栏,你可以作弊:`$ request-> headers-> add(array('X-Requested-With'=>'XMLHttpRequest'));`那是因为在WebProfilerBundle/EventListener中/WebDebugToolbarListener.php在注入工具栏之前有一个明确的检查. (2认同)

Tib*_*Tib 16

如果在config.yml中设置framework.profiler.collectfalse,则不会显示探查器栏(即使web_profiler.toolbar设置为true).

 framework:
    profiler:
        collect: false
Run Code Online (Sandbox Code Playgroud)

然后,您可以手动选择性地激活代码中的收集器,如下所示:

$this->container->get('profiler')->enable();
Run Code Online (Sandbox Code Playgroud)

文档:http://symfony.com/doc/current/reference/configuration/framework.html#collect


Art*_*Bay 6

交响乐 5.3.7

我在 web_profiler.yaml 中将工具栏值更改为 false,并且工具栏被禁用。

{# [root_directory]/config/packages/dev/web_profiler.yaml #}

web_profiler:
    toolbar: true  --> Change to false
    intercept_redirects: false
Run Code Online (Sandbox Code Playgroud)


小智 5

试试这个

framework:
    profiler: { only_exceptions: true }
Run Code Online (Sandbox Code Playgroud)

在你的 app/config/config_dev.yml


Ada*_*ney 5

如果您从Symfony 2.5开始创建了一个新的Symfony项目,则会设置这些参数 app/config/paramaters.yml

parameters:
    # ...
    debug_toolbar: true
    debug_redirects: false
Run Code Online (Sandbox Code Playgroud)

只是设置debug_toolbarfalse.