From 13015adbeaa83f0c8759ab4ca604087c0b1a6266 Mon Sep 17 00:00:00 2001 From: Hidde Wieringa Date: Sat, 1 Oct 2016 18:17:27 +0200 Subject: [PATCH] Added the VarDumper to the debug/debugging page --- debug/debugging.rst | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/debug/debugging.rst b/debug/debugging.rst index dacf9eab285..ffc58e9daec 100644 --- a/debug/debugging.rst +++ b/debug/debugging.rst @@ -59,3 +59,28 @@ locations. To avoid problems, you can either tell your IDE to ignore the PHP cache files, or you can change the extension used by Symfony for these files:: $kernel->loadClassCache('classes', '.php.cache'); + +Using the VarDumper +------------------- + +To ease the debugging of a variable in your application, you can use the +``VarDumper`` component to dump the content of a variable. The component +provides an alternative to the PHP ``var_dump`` function, in the form of +``dump``. + +It is as easy as the code below:: + + // Create a variable with a value... + $myVar = ...; + + // ... and dump it + dump($myVar); + +.. tip:: + + The dumper is not limited to scalar values. Arrays and objects can also be + visualized using the ``VarDumper``. + +If the dumper is used on a command line, the result is a formatted string. +Otherwise, the result is a piece of HTML, which can be expanded to show nested +structures in the dumped value.