You are browsing the Symfony 4 documentation, which changes significantly from Symfony 3.x. If your app doesn't use Symfony 4 yet, browse the Symfony 3.4 documentation.

How to Use Matchers to Enable the Profiler Conditionally

How to Use Matchers to Enable the Profiler ConditionallyΒΆ

Caution

The possibility to use a matcher to enable the profiler conditionally was removed in Symfony 4.0.

Symfony Profiler cannot be enabled/disabled conditionally using matchers, because that feature was removed in Symfony 4.0. However, you can use the enable() and disable() methods of the Profiler class in your controllers to manage the profiler programmatically:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
use Symfony\Component\HttpKernel\Profiler\Profiler;
// ...

class DefaultController
{
    // ...

    public function someMethod(Profiler $profiler)
    {
        // for this particular controller action, the profiler is disabled
        $profiler->disable();

        // ...
    }
}

This work, including the code samples, is licensed under a Creative Commons BY-SA 3.0 license.