How do I disable the Symfony 2 profiler bar?

限于喜欢 提交于 2019-12-03 01:36:01

问题


It's not adding anything and it makes the page slower and I want it gone. Don't ask. There's little about the profiler on the website and nothing in the app config.


回答1:


This setting is in app/config/config_dev.yml:

web_profiler:
    toolbar: true
    intercept_redirects: false



回答2:


Additional: if you want to disable it for a special action in your controller than use this:

if ($this->container->has('profiler'))
{
    $this->container->get('profiler')->disable();
}



回答3:


If you set framework.profiler.collect to false in your config.yml, the profiler bar won't be shown (even if web_profiler.toolbar is set to true).

 framework:
    profiler:
        collect: false

This then allows you to selectively activate collectors in your code manually, like this:

$this->container->get('profiler')->enable();

Documentation here: http://symfony.com/doc/current/reference/configuration/framework.html#collect




回答4:


Try this

framework:
    profiler: { only_exceptions: true }

in your app/config/config_dev.yml




回答5:


If you have created a new Symfony project since Symfony 2.5, these parameters are set in app/config/paramaters.yml

parameters:
    # ...
    debug_toolbar: true
    debug_redirects: false

Just set debug_toolbar to false.




回答6:


To still get output in /_profiler but without the toolbar, you can cheat:

$request->headers->add(array('X-Requested-With' => 'XMLHttpRequest'));

That's because in WebProfilerBundle/EventListener/WebDebugToolbarListener.php there's an explicit check for this before injecting the toolbar.




回答7:


If you are worried about performance - then you should not be running under dev. Dev also limits caching and can pull in additional bundles.

Run in prod mode and warm your cache before you run performance tests.




回答8:


Another way that seems to disable it, is to not have _dev in the routing of the application.

So for me in a bitnami install of Symfony 2, simply by changing app/conf/httpd-app.conf slightly it would change the program:

RewriteBase /symfony/app_dev.php

to

RewriteBase /symfony/

and it would keep the toolbar from coming up.



来源:https://stackoverflow.com/questions/8749939/how-do-i-disable-the-symfony-2-profiler-bar

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