Skip to content

Adding check for environments #10239

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 5, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions profiler/matchers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,13 @@ class in your controllers to manage the profiler programmatically::
{
// ...

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

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

.. code-block:: yaml

# config/services.yaml
# config/dev/services.yaml
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be config/services_dev.yaml instead?

services:
Symfony\Component\HttpKernel\Profiler\Profiler: '@profiler'

.. code-block:: xml

<!-- config/services.xml -->
<!-- config/dev/services.xml -->
<?xml version="1.0" encoding="UTF-8" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
Expand All @@ -57,7 +60,7 @@ create an alias pointing to the existing ``profiler`` service:

.. code-block:: php

// config/services.php
// config/dev/services.php
use Symfony\Component\HttpKernel\Profiler\Profiler;

$container->setAlias(Profiler::class, 'profiler');