File tree Expand file tree Collapse file tree 2 files changed +41
-0
lines changed Expand file tree Collapse file tree 2 files changed +41
-0
lines changed Original file line number Diff line number Diff line change @@ -21,3 +21,4 @@ install the profiler before using it:
2121 profiler/profiling_data
2222 profiler/matchers
2323 profiler/storage
24+ profiler/wdt_follow_ajax
Original file line number Diff line number Diff line change 1+ .. index ::
2+ single: Profiling: WDT Auto-update after AJAX Request
3+
4+ How to Make the Web Debug Toolbar Auto-update After AJAX Requests
5+ ================================================================
6+
7+ For single page applications it would be more convenient if the toolbar
8+ showed the information for the most recent AJAX request instead of the
9+ initial page load.
10+
11+ By setting the ``Symfony-Debug-Toolbar-Replace `` header to a value of ``1 `` in the
12+ AJAX request, the toolbar will be automatically reloaded for the request. The
13+ header can be set on the response object::
14+
15+ $response->headers->set('Symfony-Debug-Toolbar-Replace', 1);
16+
17+ Only Setting the Header During Development
18+ -------------------------------------------
19+
20+ Ideally this header should only be set during development and not for
21+ production. This can be accomplished by setting the header in a
22+ :ref: `kernel.response <component-http-kernel-kernel-response >` event listener::
23+
24+ public function onKernelResponse(FilterResponseEvent $event)
25+ {
26+ $response = $event->getResponse();
27+
28+ $response->headers->set('Symfony-Debug-Toolbar-Replace', 1);
29+ }
30+
31+ .. seealso ::
32+
33+ Read more Symfony events :ref: `/reference/events `.
34+
35+ If you are using Symfony Flex, you should define your event listener service in the
36+ ``config/services_dev.yml `` file so that it only exists in the ``dev `` environment.
37+
38+ .. seealso ::
39+
40+ Read more on creating dev only services :ref: `/configuration/configuration_organization `.
You can’t perform that action at this time.
0 commit comments