@@ -86,27 +86,35 @@ that can help you visualize and find the information.
86
86
When in doubt how to use a console command, open the help section by
87
87
appending the ``--help `` option.
88
88
89
- Using the VarDumper
90
- -------------------
89
+ Dumping Variables with the VarDumper
90
+ ------------------------------------
91
91
92
92
To ease the debugging of a variable in your application, you can use the
93
- `` VarDumper `` component to dump the content of a variable. The component
94
- provides an alternative to the PHP `` var_dump `` function, in the form of
95
- ``dump ``.
93
+ :doc: ` VarDumper component < /components/var_dumper >` to dump the content of a
94
+ variable. The component provides an alternative to the PHP :phpfunction: ` var_dump() `
95
+ function, in the form of ``dump() ``::
96
96
97
- It is as easy as the code below::
98
-
99
- // Create a variable with a value...
97
+ // create a variable with a value
100
98
$myVar = ...;
101
99
102
- // ... and dump it
100
+ // and dump it
103
101
dump($myVar);
104
102
105
- .. tip ::
106
-
107
- The dumper is not limited to scalar values. Arrays and objects can also be
108
- visualized using the `` VarDumper `` .
103
+ The dumper is not limited to scalar values. Arrays and objects can also be
104
+ visualized using the VarDumper. One of the most important advantages of using
105
+ `` dump() `` is a nicer and more specialized dump of objects (e.g. Doctrine
106
+ internals are filtered out when dumping a proxy entity) .
109
107
110
108
If the dumper is used on a command line, the result is a formatted string.
111
109
Otherwise, the result is a piece of HTML, which can be expanded to show nested
112
110
structures in the dumped value.
111
+
112
+ You can also dump values from inside templates:
113
+
114
+ .. code-block :: html+twig
115
+
116
+ {# dumps the variable inline as HTML #}
117
+ {{ dump(myVar) }}
118
+
119
+ {# dumps the variable to the web debug toolbar to not modify the template #}
120
+ {% dump myVar %}
0 commit comments