Bill Shupp Software engineer, photographer, musician, space geek

18Apr/113

More on step debugging in PHP

Having recently wrote about PHP step debugging in VIM, I thought I'd share a couple of things I've come across since writing it.

First, I find that I often need step debugging when writing unit tests, as that's when I'm really scrutinizing logic.  It turns out it's pretty easy to do.  All you need is to set the XDEBUG_CONFIG environment variable like so:

XDEBUG_CONFIG="idekey=session_name" php bin/phpunit.php tests/FooTest.php

When debugging from VIM, you'll want to have two shells open. One running the debugger, and another executing the tests. Also, note that in a shared environment, you can still pass in xdebug ini settings like so:

XDEBUG_CONFIG="idekey=session_name" \
php -d xdebug.remote_host=10.0.0.1 bin/phpunit.php tests/FooTest.php

Second, for step debugging in VIM, I've settled on this plugin (there are many versions out there).  It seems to solve problems with tab handling that I was seeing with older versions.

Cheers,

Bill

 

UPDATE: There's a new VIM plugin that's much better for step debugging.  Check out the announcement here: http://joncairns.com/2012/08/vdebug-a-dbgp-debugger-client-for-vim-supporting-php-python-perl-and-ruby/