Debugging on the Command Line with xdebug


Thanks to some help from Derick and my co-worker Trevor, I now have a simple bash script that will let me and my team easily debug CLI scripts on our development server.

The script is as follows:

XDEBUG_CONFIG=”idekey=YOURIDEKEYHERE” php -dxdebug.remote_host=`echo $SSH_CLIENT | cut -d “=” -f 2 | awk ‘{print $1}’` $1

This simple script will use your SSH_CLIENT environment variable to set the xdebug.remote_host setting correctly. Just set your idekey, and you’re good to go.

I put it in /usr/local/bin/xdebug and you call it simply with xdebug file.php with your debugger
running on the machine you’re SSH’ing from.

Works great!

– Davey

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>