Symfony 2.6 includes the brand new VarDumper component
Now why is a new var dump variant such a big deal?
There are several reasons why dump() is great:
- It is available in any layer of the application, including controllers, services and the twig template engine.
- It has serveral advanced features like partial or shallow dumps of object trees. Anyone who ever tried var_dump for a doctrine entity knows why this is valuable.
- It’s output is nicely integrated into the Web Debug Toolbar and into the Symfony Profiler, see screenshots below.
As an example, the following code is executed during the request (in this case in a controller):
$foo = array('a', 'b', 'c'); dump($foo);
This is what the output looks like: when hovering over the dump symbol in the Web Debug Toolbar:
This is the dump panel inside the profiler:
Enjoy efficient debugging!