File tree Expand file tree Collapse file tree 1 file changed +9
-6
lines changed
Filter options
Expand file tree Collapse file tree 1 file changed +9
-6
lines changed
Original file line number Diff line number Diff line change @@ -21,10 +21,13 @@ class in your controllers to manage the profiler programmatically::
21
21
{
22
22
// ...
23
23
24
- public function someMethod(Profiler $profiler)
24
+ public function someMethod(? Profiler $profiler)
25
25
{
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
+ }
28
31
29
32
// ...
30
33
}
@@ -37,13 +40,13 @@ create an alias pointing to the existing ``profiler`` service:
37
40
38
41
.. code-block :: yaml
39
42
40
- # config/services.yaml
43
+ # config/dev/ services.yaml
41
44
services :
42
45
Symfony\Component\HttpKernel\Profiler\Profiler : ' @profiler'
43
46
44
47
.. code-block :: xml
45
48
46
- <!-- config/services.xml -->
49
+ <!-- config/dev/ services.xml -->
47
50
<?xml version =" 1.0" encoding =" UTF-8" ?>
48
51
<container xmlns =" http://symfony.com/schema/dic/services"
49
52
xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
@@ -57,7 +60,7 @@ create an alias pointing to the existing ``profiler`` service:
57
60
58
61
.. code-block :: php
59
62
60
- // config/services.php
63
+ // config/dev/ services.php
61
64
use Symfony\Component\HttpKernel\Profiler\Profiler;
62
65
63
66
$container->setAlias(Profiler::class, 'profiler');
You can’t perform that action at this time.
0 commit comments