Quantcast
Channel: Symfony Blog
Viewing all articles
Browse latest Browse all 3059

New in Symfony 4.1: Self-updating debug toolbar

$
0
0
Jeffrey Brubaker

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 specialSymfony-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:

1
$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.


Be trained by Symfony experts - 2018-05-14 Paris - 2018-05-14 Paris - 2018-05-16 Paris

Viewing all articles
Browse latest Browse all 3059

Trending Articles