1
1
.. index ::
2
2
single: Debugging
3
3
4
- How to Optimize your Development Environment for Debugging
4
+ How to Optimize Your Development Environment for Debugging
5
5
==========================================================
6
6
7
7
When you work on a Symfony project on your local machine, you should use the
8
8
``dev `` environment (``app_dev.php `` front controller). This environment
9
- configuration is optimized for two main purposes.
9
+ configuration is optimized for two main purposes:
10
10
11
11
* Give the developer accurate feedback whenever something goes wrong (provided
12
12
by the web debug toolbar, nice exception pages, profiler, ...);
13
- * Be as similar as possible as the production environment to avoid problems
14
- when deploying the project.
13
+ * Be as close as possible to the production environment to avoid problems when
14
+ deploying the project.
15
15
16
16
Using Interactive Debug Tools
17
17
-----------------------------
18
18
19
19
Interactive debug tools allow you to walk through the code step by step,
20
- making it easier to indentify which step is causing problems. Symfony works
20
+ making it easier to identify which step is causing problems. Symfony works
21
21
with any PHP debug environment, among them:
22
22
23
- * Xdebug _ , the most well-known PHP debugger;
24
- * PsySH _ , a PHP REPL _ (Read-eval-print loop) debugger. Use the
25
- FidryPsyshBundle _ for a dedicated Symfony integration of PsySH.
23
+ * ` Xdebug `_ , the most well-known PHP debugger;
24
+ * ` PsySH `_ , a PHP ` REPL `_ (Read-eval-print loop) debugger. Use the
25
+ ` FidryPsyshBundle `_ for a dedicated Symfony integration of PsySH.
26
26
27
27
Disabling the Bootstrap File and Class Caching
28
28
----------------------------------------------
@@ -60,8 +60,8 @@ below::
60
60
61
61
.. tip ::
62
62
63
- If you disable the PHP caches, don't forget to revert after your debugging
64
- session.
63
+ If you disable the PHP caches, don't forget to revert these changes after
64
+ your debugging session.
65
65
66
66
Some IDEs do not like the fact that some classes are stored in different
67
67
locations. To avoid problems, you can either tell your IDE to ignore the PHP
@@ -74,8 +74,8 @@ Dumping Variables with the VarDumper
74
74
75
75
To ease the debugging of a variable in your application, you can use the
76
76
:doc: `VarDumper component </components/var_dumper >` to dump the content of a
77
- variable. The component provides an alternative to the PHP :phpfunction: ` var_dump () `
78
- function, in the form of `` dump () `` ::
77
+ variable. The component provides the `` dump () `` function, an alternative to
78
+ PHP's :phpfunction: ` var_dump () ` function ::
79
79
80
80
// create a variable with a value
81
81
$myVar = ...;
@@ -86,7 +86,7 @@ function, in the form of ``dump()``::
86
86
The dumper is not limited to scalar values. Arrays and objects can also be
87
87
visualized using the VarDumper. One of the most important advantages of using
88
88
``dump() `` is a nicer and more specialized dump of objects (e.g. Doctrine
89
- internals are filtered out when dumping a proxy entity).
89
+ internals are filtered out when dumping an entity proxy ).
90
90
91
91
If the dumper is used on a command line, the result is a formatted string.
92
92
Otherwise, the result is a piece of HTML, which can be expanded to show nested
@@ -107,14 +107,14 @@ Useful Debugging Commands
107
107
108
108
When developing a large application, it can be hard to keep track of all the
109
109
different services, routes and translations. Luckily, Symfony has some commands
110
- that can help you visualize and find the information.
110
+ that can help you visualize and find the information:
111
111
112
112
``debug:container ``
113
113
Displays information about the contents of the Symfony container for all public
114
- services. To find only those matching a name, append the name as an argument .
114
+ services. Append a service ID as an argument to find only those matching the ID .
115
115
116
116
``debug:config ``
117
- Shows all configured bundles, their class and their alias .
117
+ Shows all configured bundles, their classes and their aliases .
118
118
119
119
``debug:event-dispatcher ``
120
120
Displays information about all the registered listeners in the event dispatcher.
@@ -123,15 +123,19 @@ that can help you visualize and find the information.
123
123
Displays information about all configured routes in the application as a
124
124
table with the name, method, scheme, host and path for each route.
125
125
126
+ ``router:match <path_info> ``
127
+ Shows the route information matching the provided path info or an error if
128
+ no route matches.
129
+
126
130
``debug:translation <locale> ``
127
131
Shows a table of the translation key, the domain, the translation and the
128
- fallback translation for all known messages, if translations exist for
132
+ fallback translation for all known messages if translations exist for
129
133
the given locale.
130
134
131
135
.. tip ::
132
136
133
137
When in doubt how to use a console command, open the help section by
134
- appending the ``--help `` option.
138
+ appending the ``--help `` (`` -h ``) option.
135
139
136
140
.. tip ::
137
141
0 commit comments