New in Symfony 2.7: VarDumper improvements
April 27, 2015 • Published by Javier Eguiluz
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
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:
In Symfony 2.7, thanks to the new specialized caster for PHP reflection classes, you'll see a much better dump:
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.
Comments are closed.
To ensure that comments stay relevant, they are closed for old posts.
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.