Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 1bbca83

Browse filesBrowse files
jeffreymbjaviereguiluz
authored andcommitted
WDT following AJAX requests
1 parent 8a83d17 commit 1bbca83
Copy full SHA for 1bbca83

File tree

2 files changed

+41
-0
lines changed
Filter options

2 files changed

+41
-0
lines changed

‎profiler.rst

Copy file name to clipboardExpand all lines: profiler.rst
+1
Original file line numberDiff line numberDiff 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

‎profiler/wdt_follow_ajax.rst

Copy file name to clipboard
+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
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`.

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.