I am using symfony2 and its debug toolbar is great.
However, I\'ve come to install som extra bundles which add some elements and it is now displayed on two levels.
I had issue with php-cache. It had CacheDataCollector which could crash symfony2 in some cases - https://github.com/php-cache/issues/issues/112 I tried solution above (with priority 0) - and it doesnt worked, data-collector still crashed symfony2
I dont have any ideas why priority = 0 should disable anything. You could check symfony2 ProfilerPass yourself, which process tag data_collector in https://github.com/avorobiev/symfony2/blob/master/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/ProfilerPass.php
So, I have used pretty dirty patch intead - in application config I add service with the same name, but without tag data_collector. Like
services:
cache.data_collector:
class: Cache\CacheBundle\DataCollector\CacheDataCollector
More clean and more stable way would be adding CompilerPass, which will remove tag - https://blog.liplex.de/disable-elements-in-the-symfony-developer-toolbar-with-compilerpass/
Elements of the toolbar are called DataCollectors
, they are special services tagged with data_collector
. In the following lines, i will take the Time Datacollector
as example.
So in order to deactivate one of them, you first have to get his service id.
You can list all the DataCollectors
by running the console command:
php console container:debug --show-private --tag='data_collector'
The output is:
[container] Public and private services with tag data_collector
Service ID template id priority Class name
9d48641ce55174a7d8ab08e99157426bc290884423a78a5821440d644f6a37df_5 @WebProfiler/Collector/time.html.twig time 300 Symfony\Component\HttpKernel\DataCollector\TimeDataCollector
So now you got the id of the service which is time
, you have to build the name. Add data_collector.
as a prefix of the id to get the name. The name of the service is data_collector.time
.
Now as you want to deactivate it, you have to give it a Zero priority.
In your config.yml:
services:
data_collector.time:
class: "%data_collector.time.class%"
tags:
- {name: 'data_collector', priority: '0'}
Now the profiler doesn't have the time
no more.
This is a way to unable some profiler items properly. ( A.K.A: A symfony update won't affect it, unless they change the name of the DataCollectors )
The shortiest way is to direcly put the zero priority in vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Resources/config/collectors.xml
<?xml version="1.0" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
<parameters>
<parameter key="data_collector.config.class">Symfony\Component\HttpKernel\DataCollector\ConfigDataCollector</parameter>
<parameter key="data_collector.request.class">Symfony\Component\HttpKernel\DataCollector\RequestDataCollector</parameter>
<parameter key="data_collector.exception.class">Symfony\Component\HttpKernel\DataCollector\ExceptionDataCollector</parameter>
<parameter key="data_collector.events.class">Symfony\Component\HttpKernel\DataCollector\EventDataCollector</parameter>
<parameter key="data_collector.logger.class">Symfony\Component\HttpKernel\DataCollector\LoggerDataCollector</parameter>
<parameter key="data_collector.time.class">Symfony\Component\HttpKernel\DataCollector\TimeDataCollector</parameter>
<parameter key="data_collector.memory.class">Symfony\Component\HttpKernel\DataCollector\MemoryDataCollector</parameter>
<parameter key="data_collector.router.class">Symfony\Bundle\FrameworkBundle\DataCollector\RouterDataCollector</parameter>
</parameters>
<services>
[...]
<service id="data_collector.time" class="%data_collector.time.class%" public="false">
<tag name="data_collector" template="@WebProfiler/Collector/time.html.twig" id="time" priority="0" />
<argument type="service" id="kernel" on-invalid="ignore" />
<argument type="service" id="debug.stopwatch" on-invalid="ignore" />
</service>
[..]
</services>
</container>
All the DataCollectors are not defined in the same file. But here is a quick list of some of them:
data_collector.config:
data_collector.request:
data_collector.router:
data_collector.security:
data_collector.logger:
data_collector.memory:
data_collector.exception:
data_collector.events:
swiftmailer.data_collector: