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.

Finally an easy way to test your .htaccess file

April 1, 2014 at 11:31 am

Ever write a long complicated .htaccess file only to not have it work like you thought it would? Then this tool is for you:

Posting an Array to a URL using Curl

April 1, 2014 at 8:51 am

Adding this snippet because I often find myself needing this. This will allow you to grab a url using CURL while posting variables to that URL.

    function makeCurlCall($url, $json = array())
	$ch = curl_init();
        curl_setopt($ch, CURLOPT_VERBOSE, false);
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_FAILONERROR, 0);
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
        curl_setopt($ch, CURLOPT_TIMEOUT, 10);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

        if (!empty($json))
            curl_setopt($ch, CURLOPT_POST, 1);
            curl_setopt($ch, CURLOPT_POSTFIELDS, $json);
            curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
        return curl_exec($ch);