Disable elements in the Symfony developer toolbar

There are a lot of handy elements in the Symfony toolbar. But I think - especially with the last version - the toolbar got a little bit crowded. There are just a few elements I don't need (at least not for now). So I looked into how to remove them.


Update: There is also a way to do the same thing with a CompilerPass.


Turns out they are called data_collector services. On of there settings is priority. When overwriting them with '0' in (for example) your global services.yml, they become deactivated.

A few of the services have additional arguments like a class which you have to specify. To see that, just search for data-collector. + collector name and look into the definition of the service. You can see which ones are active and there names with the following command:

$ php app/console container:debug --show-private --tag='data_collector'

The overwritten services can look like the following:

services:

    data_collector.translation:
        class: 'Symfony\Component\Translation\DataCollector\TranslationDataCollector'
        tags:
           - {name: 'data_collector', priority: '0'}
        arguments: [@translator.data_collector]

    data_collector.form:
        class: "%data_collector.form.class%"
        tags:
           - {name: 'data_collector', priority: '0'}
        arguments: [@data_collector.form.extractor]

    data_collector.logger:
        class: "%data_collector.logger.class%"
        tags:
           - {name: 'data_collector', priority: '0'}
        arguments: [@logger]

    data_collector.ajax:
        class: 'Symfony\Bundle\FrameworkBundle\DataCollector\AjaxDataCollector'
        tags:
           - {name: 'data_collector', priority: '0'}

    data_collector.twig:
        class: 'Symfony\Bridge\Twig\DataCollector\TwigDataCollector'
        tags:
           - {name: 'data_collector', priority: '0'}
        arguments: [@twig.profile]