Symfony 6 Certification New exam with updated questions 100% online Show your expertise

New in Symfony 2.8: 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 provides mechanisms for walking through any arbitrary PHP variable. More importantly, it provides a much better replacement for PHP's var_dump() called dump().

Symfony 2.8 added new casters to VarDumper, which are responsible to format the dumped information accordingly to their types.

Added caster for pgsql resources

Contributed by
Nicolas Grekas
in #15555.

PostgreSQL databases are increasingly popular among Symfony developers. That's why Symfony 2.8 includes a PgSqlCaster to cast both connections and results.

When dumping a database connection, instead of seeing just a pgsql link resource string, you can now see lots of features of that connection:

Same goes for dumping the result of executing PostgreSQL queries, which now displays detailed information about the results:

Added caster for SPLFileInfo

Contributed by
Grégoire Pineau in #14424.

This caster displays detailed information about dumped SplFileInfo objects. These are for instance the objects returned by the Finder component.

Added casters for generators, reflection and outer iterators

Contributed by
Nicolas Grekas
in #16325 and #15787.

In addition to the previous casters, VarDumper added other casters useful for generators and OuterIterator objects.

Better formatting of PHP + Twig code snippets in backtraces

Contributed by
Nicolas Grekas
in #15838.

Lastly, another nice improvement of VarDumper is the formatting of PHP and Twig code snippets in backtraces. Previously, when dumping an exception you had access to the basic stack trace:

In Symfony 2.8, the exceptions not only display the file path and line which caused the exception, but also include a formatted excerpt of the code which triggered the exception:

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.


wow this month is hot
Nice !!
Nice features!
Nice one!
I love that feature!
Really awesome!! ^_^
Nice improvements.

Comments are closed.

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