From acce1798776617bcda5817b0e8bcf5051a02191f Mon Sep 17 00:00:00 2001 From: Jeffrey Brubaker Date: Fri, 27 Apr 2018 05:56:09 +0300 Subject: [PATCH 1/3] First attempt at documenting the WDT following AJAX requests --- profiler.rst | 1 + profiler/wdt_follow_ajax.rst | 40 ++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 profiler/wdt_follow_ajax.rst diff --git a/profiler.rst b/profiler.rst index ca3458bcf06..968fbb5728f 100644 --- a/profiler.rst +++ b/profiler.rst @@ -21,3 +21,4 @@ install the profiler before using it: profiler/profiling_data profiler/matchers profiler/storage + profiler/wdt_follow_ajax diff --git a/profiler/wdt_follow_ajax.rst b/profiler/wdt_follow_ajax.rst new file mode 100644 index 00000000000..ff70fbede78 --- /dev/null +++ b/profiler/wdt_follow_ajax.rst @@ -0,0 +1,40 @@ +.. index:: + single: Profiling: WDT Auto-update after AJAX Request + +How to make the Web Debug Toolbar Auto-upate after AJAX Requests +================================================================ + +For single page applications it is often inconvenient to find the profiler +information for the most recent request. It would be much more convient if it +the toolbar would show the information from the most recent AJAX request +instead of your initial page load. + +By setting the `Symfony-Debug-Toolbar-Replace` to a value of `1` in the +AJAX request, the toolbar will be automatically reloaded for the request. The +header can be set on the response object:: + + $response->headers->set('Symfony-Debug-Toolbar-Replace', 1); + +Only setting the header durring development +------------------------------------------- + +Ideally this header should only be set durring development and not for +production. This can be accomplished by setting the header in a +:ref:`kernel.response ` event listener:: + + public function onKernelResponse(FilterResponseEvent $event) + { + $response = $event->getResponse(); + + $response->headers->set('Symfony-Debug-Toolbar-Replace', 1); + } + +.. seealso:: + + Read more Symfony events :ref:`/reference/events`. + +If you are using Symfony Flex, you should define your event listener service in the ``config/services_dev.yml`` file so that it only exists in the ``dev`` environment. + +.. seealso:: + + Read more on creating dev only services :ref:`/configuration/configuration_organization`. \ No newline at end of file From b022371ba3b64fbb9776c110d92b5bfcdb131774 Mon Sep 17 00:00:00 2001 From: Jeffrey Brubaker Date: Mon, 30 Apr 2018 10:59:11 +0300 Subject: [PATCH 2/3] Misc typo fixes and improvements from PR. --- profiler/wdt_follow_ajax.rst | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/profiler/wdt_follow_ajax.rst b/profiler/wdt_follow_ajax.rst index ff70fbede78..a6a1dc175b6 100644 --- a/profiler/wdt_follow_ajax.rst +++ b/profiler/wdt_follow_ajax.rst @@ -1,24 +1,23 @@ .. index:: single: Profiling: WDT Auto-update after AJAX Request -How to make the Web Debug Toolbar Auto-upate after AJAX Requests +How to make the Web Debug Toolbar Auto-update after AJAX Requests ================================================================ -For single page applications it is often inconvenient to find the profiler -information for the most recent request. It would be much more convient if it -the toolbar would show the information from the most recent AJAX request -instead of your initial page load. +For single page applications it would be more convenient if the toolbar +showed the information for the most recent AJAX request instead of the +initial page load. -By setting the `Symfony-Debug-Toolbar-Replace` to a value of `1` in the +By setting the `Symfony-Debug-Toolbar-Replace` header to a value of `1` in the AJAX request, the toolbar will be automatically reloaded for the request. The header can be set on the response object:: $response->headers->set('Symfony-Debug-Toolbar-Replace', 1); -Only setting the header durring development +Only setting the header during development ------------------------------------------- -Ideally this header should only be set durring development and not for +Ideally this header should only be set during development and not for production. This can be accomplished by setting the header in a :ref:`kernel.response ` event listener:: @@ -33,8 +32,9 @@ production. This can be accomplished by setting the header in a Read more Symfony events :ref:`/reference/events`. -If you are using Symfony Flex, you should define your event listener service in the ``config/services_dev.yml`` file so that it only exists in the ``dev`` environment. +If you are using Symfony Flex, you should define your event listener service in the +``config/services_dev.yml`` file so that it only exists in the ``dev`` environment. .. seealso:: - Read more on creating dev only services :ref:`/configuration/configuration_organization`. \ No newline at end of file + Read more on creating dev only services :ref:`/configuration/configuration_organization`. From 34bc79746f0d6e727f558fb5c92c97154fd5710c Mon Sep 17 00:00:00 2001 From: Jeffrey Brubaker Date: Mon, 30 Apr 2018 12:39:42 +0300 Subject: [PATCH 3/3] Additional improvments from review --- profiler/wdt_follow_ajax.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/profiler/wdt_follow_ajax.rst b/profiler/wdt_follow_ajax.rst index a6a1dc175b6..cf76609f0ab 100644 --- a/profiler/wdt_follow_ajax.rst +++ b/profiler/wdt_follow_ajax.rst @@ -1,20 +1,20 @@ .. index:: single: Profiling: WDT Auto-update after AJAX Request -How to make the Web Debug Toolbar Auto-update after AJAX Requests +How to Make the Web Debug Toolbar Auto-update After AJAX Requests ================================================================ For single page applications it would be more convenient if the toolbar showed the information for the most recent AJAX request instead of the initial page load. -By setting the `Symfony-Debug-Toolbar-Replace` header to a value of `1` in the +By setting the ``Symfony-Debug-Toolbar-Replace`` header to a value of ``1`` in the AJAX request, the toolbar will be automatically reloaded for the request. The header can be set on the response object:: $response->headers->set('Symfony-Debug-Toolbar-Replace', 1); -Only setting the header during development +Only Setting the Header During Development ------------------------------------------- Ideally this header should only be set during development and not for