Symfony 6 Certification New exam with updated questions 100% online Show your expertise

New in Symfony 4.1: Self-updating debug toolbar

Warning: This post is about an unsupported Symfony version. Some of this information may be out of date. Read the most recent Symfony Docs.

Contributed by
Jeffrey Brubaker
in #26655.

Single-page applications (SPA) are web applications that use JavaScript to rewrite the current page contents dynamically rather than loading entire new pages from the backend.

One of the problems of working on those applications is that Symfony's Web Debug Toolbar remains unchanged with the debug information of the first action executed when browsing the application.

In order to solve this issue, in Symfony 4.1 we've introduced a special Symfony-Debug-Toolbar-Replace HTTP header. Set its value to 1 to tell Symfony to replace the web debug toolbar with the new one associated with the current response.

If you want to enable this behavior for just one response, add this to your code:

$response->headers->set('Symfony-Debug-Toolbar-Replace', 1);

If you work on a SPA application, it's better to define an event subscriber and listen to the kernel.response event to add that header automatically.

Help the Symfony project!

As with any Open-Source project, contributing code or documentation is the most common way to help, but we also have a wide range of sponsoring opportunities.


Nice one! Thanks!
nice ! especially helpful for nelmio api doc !!
Excellent! Thks.
Awesome feature :P
Excellent feature! Thank you very much!
Very nice, thanks!
Awesome! Thanks
This is very cool! We're getting so much closer to awesome SPA debug support.
Great as always

Comments are closed.

To ensure that comments stay relevant, they are closed for old posts.