Back to symfony.com

Lesson 7 of 11 · 2 min

Click any paragraph or press to highlight its code

The profiler

Symfony's debugging experience is one of its superpowers. Install it with one command.

Every page now shows a debug toolbar at the bottom: request time, memory, database queries, logs, deprecations... Click any value to open the full profiler, which keeps a detailed trace of every request, even redirects and API calls.

And forget var_dump() + die(): the dump() function sends any variable, beautifully formatted, to the toolbar without breaking the page.

$ composer require profiler
<?phpnamespace App\Controller;use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;use Symfony\Component\HttpFoundation\Response;use Symfony\Component\Routing\Attribute\Route;class CheckoutController extends AbstractController{    #[Route('/checkout')]    public function checkout(): Response    {        $cart = ['items' => 3, 'total' => 41.5];        // inspect it in the toolbar, no var_dump() + die() needed        dump($cart);        return $this->render('checkout/index.html.twig', [            'cart' => $cart,        ]);    }}