php-schulung.de

Symfony 2.6 includes the brand new VarDumper component

By am 06.12.2014 in Blog, Symfony

The VarDumper Symfony component has been released with Symfony 2.6. Details about its history can be found on Github.

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!

Kommentieren

Kommentare bitte per Twitter an @PHP_Schulung senden.