Skip to content

Commit 723fe9e

Browse files
committed
minor #18144 [Profiler] Add conditional profiling example config (andreybolonin)
This PR was squashed before being merged into the 6.2 branch. Discussion ---------- [Profiler] Add conditional profiling example config According to https://symfony.com/blog/new-in-symfony-5-4-profiler-improvements Commits ------- f1d0dc0 [Profiler] Add conditional profiling example config
2 parents ed094cf + f1d0dc0 commit 723fe9e

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

profiler.rst

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,27 @@ you'll need to configure the data collector explicitly:
523523
// 'priority' => 300,
524524
]);
525525
};
526+
527+
Conditional Profiling
528+
~~~~~~~~~~~~~~~~~~~~~
529+
530+
Symfony profiler provides an immense amount of debug information to quickly find the cause of any problem. However, that comes at a price, because the profiler must collect all that information while serving the request. This can slowdown the application even for requests where you don't look at the profiler information (which are most of them).
531+
532+
You can enable the profiler conditionally. To do that, add these two new config options:
533+
534+
.. configuration-block::
535+
536+
.. code-block:: yaml
537+
538+
# config/packages/dev/web_profiler.yaml
539+
framework:
540+
profiler:
541+
collect: false
542+
collect_parameter: 'profile'
543+
544+
The collect: false option disables the profiler by default and the collect_parameter: profile option enables it for requests that include the profile query parameter.
545+
546+
You can freely choose the query parameter name and you can also enable the profiler by submitting a form field with that name (useful for POST requests) and even a request attribute.
526547

527548
.. _`Single-page applications`: https://en.wikipedia.org/wiki/Single-page_application
528549
.. _`Blackfire`: https://blackfire.io/docs/introduction?utm_source=symfony&utm_medium=symfonycom_docs&utm_campaign=profiler

0 commit comments

Comments
 (0)