Print and die, with Laravel

April 15, 2014 at 2:16 pm

laravelFor long time I thought I was the strange programmer that needed something that nobody else could possibly want.

The need arises almost daily for me to see the contents of an object in PHP. XDebug and tracing through code is convenient but often overkill. Sometimes you just want to be able to:

    print '<pre>';

Sure, you might think that “var_dump” is the solution to this, but “var_dump” just solves one part of the problem, namely the printing part. So far many projects I would create my own method, called “p”. It would often do the trick:

    function p($object) {

Which I could then call:


It wasn’t until Laravel that I’ve come across a built-in way to get this done quickly and without adding any extra fuzz.


You can read more about the “dd” function here.

And FYI, Laravel rocks! I’ll be posting more about it in the weeks to come. I’m still learning, but so far it kicks beats Zend and Yii by a long mile.