11..index ::
22 single: Profiling; Matchers
33
4- How to use Matchers to enable the Profiler
5- ==========================================
4+ How to use Matchers to enable the Profiler Conditionally
5+ ========================================================
66
77By 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.
1112
12- Using thebuild -in Matcher
13+ Using thebuilt -in Matcher
1314--------------------------
1415
1516Symfony2 provides a
16- :class: `build -in matcher <Symfony\\ Component\\ HttpFoundation\\ RequestMatcher> `
17- which can match paths and IPs. Forinstance, 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. Forexample, 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 :
2021
2122..configuration-block ::
2223
@@ -48,7 +49,7 @@ configured to something like this:
4849 ));
4950
5051 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
5253profiler only for the ``/admin/ `` urls.
5354
5455Creating a Custom Matcher
@@ -60,8 +61,8 @@ which implements
6061:class: `Symfony\\ Component\\ HttpFoundation\\ RequestMatcherInterface `. This
6162interface requires one method:
6263:method: `Symfony\\ Component\\ HttpFoundation\\ RequestMatcherInterface::matches `.
63- This method returnsa falsey value to disable the profiler, any other value
64- enables the profiler.
64+ This method returnsfalse to disable the profiler and true to enable the
65+ profiler.
6566
6667To enable the profiler when a ``ROLE_SUPER_ADMIN `` is logged in, you can use
6768something like::