How do I disable the Symfony 2 profiler bar?

前端 未结 8 1402
清酒与你
清酒与你 2021-01-30 10:29

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.

相关标签:
8条回答
  • 2021-01-30 10:56

    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.

    0 讨论(0)
  • 2021-01-30 10:57

    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();
    }
    
    0 讨论(0)
  • 2021-01-30 10:59

    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.

    0 讨论(0)
  • 2021-01-30 11:04

    Try this

    framework:
        profiler: { only_exceptions: true }
    

    in your app/config/config_dev.yml

    0 讨论(0)
  • 2021-01-30 11:09

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

    web_profiler:
        toolbar: true
        intercept_redirects: false
    
    0 讨论(0)
  • 2021-01-30 11:17

    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

    0 讨论(0)
提交回复
热议问题