Why I didn’t use var_dump() for a long time, even though it has very valuable information in it ? You most probably guessed it. It looks terrible. Even when you fix it with adding <pre> tags around it, it’s still ugly.
Consider this code:
$fruits = array ( "fruits" => array ( "a" => "orange",
"b" => "banana",
"c" => "apple"
"numbers" => array ( 1,
"holes" => array ( "first",
5 => "second",
Well it is turned into this:
It’s ugly! It’s so ugly! There are no other words for it.
So I could never talk myself into using it, and because of that for the past few years, I did a print_r(), wrapped in those “pre” tags.
Until I saw a screencast by Jeffrey Way on Laravel, and I saw the single most beautiful var_dump in the history of mankind.
Look at it! It’s so pretty! It’s the same data, but so much has changed!
So I wanted it too. After some googling, I found out, that it is a PHP Extension (that anyone can install) and not a Chrome extension (which was my initial guess). It’s called Xdebug, and you can get it at http://www.xdebug.org and you’ll probably want to read more about the installation ( http://xdebug.org/docs/install )
In addition, I initially thought, that I’d have some difficulties installing and setting Xdebug up, since I’m a MAMP user (I like graphical interfaces and all that good stuff, I just can’t help it, that’s why I am so excited about Xdebug after all). Turns out, that I was wrong (again).
Enabling Xdebug on MAMP (Pro) is as simple as, well – enabling Xdebug on MAMP (Pro). All you really have to do is:
- Open MAMP
- File -> Edit Template -> PHP -> PHP (your-version).ini
- Go to the very bottom and uncomment the Xdebug extension (remove the semicolon at the beginning of the line), like so:
- Restart MAMP
And That’s it! Enjoy!