Mostly we debug by using the interactive debugger (step by step etc) but sometimes one just wants to use
var_dump depending on the issue one wants to debug. There is a new library developed by Symfony that brings some advantages to
var_dump according to their documentation:
- Per object and resource types specialized view to e.g. filter out Doctrine internals while dumping a single proxy entity, or get more insight on opened files with stream_get_meta_data;
- Configurable output formats: HTML or colored command line output;
- Ability to dump internal references, either soft ones (objects or resources) or hard ones (=& on arrays or objects properties). Repeated occurrences of the same object/array/resource won't appear again and again anymore. Moreover, you'll be able to inspect the reference structure of your data;
- Ability to operate in the context of an output buffering handler.
Plan is to include this library only in development mode. Comes probably especially handy when using on the console as it provides colored debugging output and bypasses output buffering. We will be able to use those features via
dump($var1, $var2, $var3, ...).
Maybe we can declare a
dump function in case the function does not exist which is the case in the production release. Just in case anyone leaves a
dump call somewhere and it does not get noticed (neither in reviews nor in any test which is especially possible in commands since they mostly not tested)
More information: http://symfony.com/doc/current/components/var_dumper/introduction.html