Skip to content

Navigation Menu

Sign in
Appearance settings

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 8f91078

Browse filesBrowse files
authored
Adding check for environments
1 parent 2828795 commit 8f91078
Copy full SHA for 8f91078

File tree

Expand file treeCollapse file tree

1 file changed

+9
-6
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+9
-6
lines changed

‎profiler/matchers.rst

Copy file name to clipboardExpand all lines: profiler/matchers.rst
+9-6Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,13 @@ class in your controllers to manage the profiler programmatically::
2121
{
2222
// ...
2323

24-
public function someMethod(Profiler $profiler)
24+
public function someMethod(?Profiler $profiler)
2525
{
26-
// for this particular controller action, the profiler is disabled
27-
$profiler->disable();
26+
// $profiler won't be set if your environment doesn't have the profiler (like prod, by default)
27+
if ($profiler !== null) {
28+
// for this particular controller action, the profiler is disabled
29+
$profiler->disable();
30+
}
2831

2932
// ...
3033
}
@@ -37,13 +40,13 @@ create an alias pointing to the existing ``profiler`` service:
3740

3841
.. code-block:: yaml
3942
40-
# config/services.yaml
43+
# config/dev/services.yaml
4144
services:
4245
Symfony\Component\HttpKernel\Profiler\Profiler: '@profiler'
4346
4447
.. code-block:: xml
4548
46-
<!-- config/services.xml -->
49+
<!-- config/dev/services.xml -->
4750
<?xml version="1.0" encoding="UTF-8" ?>
4851
<container xmlns="http://symfony.com/schema/dic/services"
4952
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
@@ -57,7 +60,7 @@ create an alias pointing to the existing ``profiler`` service:
5760
5861
.. code-block:: php
5962
60-
// config/services.php
63+
// config/dev/services.php
6164
use Symfony\Component\HttpKernel\Profiler\Profiler;
6265
6366
$container->setAlias(Profiler::class, 'profiler');

0 commit comments

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