How do I disable the Symfony 2 profiler bar?
DebuggingSymfonyProfilerDebugging 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.