File tree Expand file tree Collapse file tree 1 file changed +9
-6
lines changed 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::
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');
You can’t perform that action at this time.
0 commit comments