New in Symfony 2.7: VarDumper improvements

Warning: This post is about an unsupported Symfony version. Some of this information may be out of date. Read the most recent Symfony Docs.

The VarDumper component was introduced in Symfony 2.6 to provide a better debugging experience. This component includes a dump() function which is a much better alternative to the regular PHP var_dump() function.

In Symfony 2.7 we made the dump() function easier to use and we also improved the dumping of complex variables such as PHP reflection classes.

Added support for recursive node toggling

Contributed by
Nicolas Grekas and Lars Wallenborn in #14071.

In Symfony 2.6, when dumping a deeply nested variable, you must click on each node arrow to reveal the contents of the nested nodes:

Symfony 2.7 removes this hassle by adding recursive toggle support. Just press the Ctrl key before clicking on any arrow and you'll toggle all the nested nodes:

Added new specialized casters

The VarDumper component uses casters to transform the objects and resources into the array-based data representation used to display the variable contents. Symfony 2.7 includes new casters to improve the debugging of Reflection classes, MongoCursor objects, XML parser resources and AMQP resources.

For example, when you dump a PHP class reflection in Symfony 2.6, you get the string representation of that reflection:

Reflection in Symfony 2.6

In Symfony 2.7, thanks to the new specialized caster for PHP reflection classes, you'll see a much better dump:

Reflection in Symfony 2.7
Help the Symfony project!

As with any Open-Source project, contributing code or documentation is the most common way to help, but we also have a wide range of sponsoring opportunities.


For sure, the XML one will be useful. Thanks.
It's patently silly that you have to ctrl+click to expand all nodes. Who wants their debugging info hidden and buried by default? Why do we have to click *at all*? Debugging shouldn't take work. I'll stick with Xdebug + var_dump() since it's actually easy to use...
@Jon when you dump complex variables, it's very convenient to not reveal all their contents by default. Hence the "click to reveal" behavior.

Regarding the use of Xdebug + var_dump(), that's definitely a very good combination and lots of Symfony developers use that. For others, the overhead introduced by Xdebug is too high and they don't want to slow down the application performance while developing it.
Another usefull feature. Thank you!

Comments are closed.

To ensure that comments stay relevant, they are closed for old posts.