Enable Profiler using URL Query Parameter in Symfony 7

Enable Profiler using URL Query Parameter in Symfony 7

Symfony framework allows using profiler that gives debug information about various application parts during development. This tutorial explains how to enable profiler using URL query parameter in Symfony 7 application.

Profiler collects a lot of information and can slow down the application. We can set profiler.collect option to false to disable the profiler by default. The profiler.collect_parameter option allows specifying the name of URL query parameter that can enable the profiler for requests.


        collect: false
        collect_parameter: 'profiler'

In our case, profiler will be only enabled if we specify the query parameter profiler with value 1 in URL (e.g. http://localhost?profiler=1).

Controller and Twig template for testing:



namespace App\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;

class TestController extends AbstractController
    public function index(): Response
        return $this->render('test/index.html.twig');


<!DOCTYPE html>
<html lang="en">
    <meta charset="UTF-8">

Leave a Comment

Cancel reply

Your email address will not be published.