How do I disable the Symfony 2 profiler bar?

DebuggingSymfonyProfiler

Debugging Problem Overview


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.

Debugging Solutions


Solution 1 - Debugging

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

web_profiler:
    toolbar: true
    intercept_redirects: false

Solution 2 - Debugging

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();
}

Solution 3 - Debugging

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

Solution 4 - Debugging

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.

Solution 5 - Debugging

Try this

framework:
    profiler: { only_exceptions: true }

in your app/config/config_dev.yml

Solution 6 - Debugging

Symfony 5.3.7

I changed the toolbar value to false in the web_profiler.yaml and the toolbar was disabled.

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

web_profiler:
    toolbar: true  --> Change to false
    intercept_redirects: false

Solution 7 - Debugging

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.

Solution 8 - Debugging

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.

Solution 9 - Debugging

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.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionRudieView Question on Stackoverflow
Solution 1 - DebuggingRudieView Answer on Stackoverflow
Solution 2 - DebuggingBesnikView Answer on Stackoverflow
Solution 3 - DebuggingTibView Answer on Stackoverflow
Solution 4 - DebuggingAdam ElsodaneyView Answer on Stackoverflow
Solution 5 - DebuggingcystbearView Answer on Stackoverflow
Solution 6 - DebuggingArtisanBayView Answer on Stackoverflow
Solution 7 - DebuggingRadu CView Answer on Stackoverflow
Solution 8 - DebuggingBillyBigPotatoesView Answer on Stackoverflow
Solution 9 - DebuggingphyattView Answer on Stackoverflow