1
1
.. index ::
2
2
single: Profiling; Matchers
3
3
4
- How to use Matchers to enable the Profiler
5
- ==========================================
4
+ How to use Matchers to enable the Profiler Conditionally
5
+ ========================================================
6
6
7
7
By default, the profiler is only activated in the development environment. But
8
- it's imaginable that a developer always wants to see the profiler, even in
9
- production. Another situation may be to show the profiler when an admin has
10
- logged in. You can enable the profiler in these situations by using matchers.
8
+ it's imaginable that a developer may want to see the profiler even in
9
+ production. Another situation may be that you want to show the profiler only
10
+ when an admin has logged in. You can enable the profiler in these situations
11
+ by using matchers.
11
12
12
- Using the build -in Matcher
13
+ Using the built -in Matcher
13
14
--------------------------
14
15
15
16
Symfony2 provides a
16
- :class: `build -in matcher <Symfony\\ Component\\ HttpFoundation\\ RequestMatcher> `
17
- which can match paths and IPs. For instance, only show the profiler when
18
- accessing the page with the ``168.0.0.1 `` ip. Then, the profiler can be
19
- configured to something like this:
17
+ :class: `built -in matcher <Symfony\\ Component\\ HttpFoundation\\ RequestMatcher> `
18
+ which can match paths and IPs. For example, if you want to only show the
19
+ profiler when accessing the page with the ``168.0.0.1 `` ip, then you can
20
+ use this configuration :
20
21
21
22
.. configuration-block ::
22
23
@@ -48,7 +49,7 @@ configured to something like this:
48
49
));
49
50
50
51
You can also set a ``path `` option to define the path on which the profiler
51
- should be enabled. For instance, setting it to `^/admin/ ` will enable the
52
+ should be enabled. For instance, setting it to `` ^/admin/ ` ` will enable the
52
53
profiler only for the ``/admin/ `` urls.
53
54
54
55
Creating a Custom Matcher
@@ -60,8 +61,8 @@ which implements
60
61
:class: `Symfony\\ Component\\ HttpFoundation\\ RequestMatcherInterface `. This
61
62
interface requires one method:
62
63
:method: `Symfony\\ Component\\ HttpFoundation\\ RequestMatcherInterface::matches `.
63
- This method returns a falsey value to disable the profiler, any other value
64
- enables the profiler.
64
+ This method returns false to disable the profiler and true to enable the
65
+ profiler.
65
66
66
67
To enable the profiler when a ``ROLE_SUPER_ADMIN `` is logged in, you can use
67
68
something like::
0 commit comments