Skip to content

Commit 4f52480

Browse files
committed
Rewrote the VarDump section a bit
1 parent bbee06d commit 4f52480

File tree

1 file changed

+21
-13
lines changed

1 file changed

+21
-13
lines changed

debug.rst

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -86,27 +86,35 @@ that can help you visualize and find the information.
8686
When in doubt how to use a console command, open the help section by
8787
appending the ``--help`` option.
8888

89-
Using the VarDumper
90-
-------------------
89+
Dumping Variables with the VarDumper
90+
------------------------------------
9191

9292
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()``::
9696

97-
It is as easy as the code below::
98-
99-
// Create a variable with a value...
97+
// create a variable with a value
10098
$myVar = ...;
10199

102-
// ... and dump it
100+
// and dump it
103101
dump($myVar);
104102

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).
109107

110108
If the dumper is used on a command line, the result is a formatted string.
111109
Otherwise, the result is a piece of HTML, which can be expanded to show nested
112110
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

Comments
 (0)