Bill Shupp Software engineer, photographer, musician, space geek


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= 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.




UPDATE: There's a new VIM plugin that's much better for step debugging.  Check out the announcement here:


Better code quality through easy access to tools

(Reposted from the Empower Campaigns blog)

When developing an application, one of the keys to maintaining high productivity and quality is to make sure that you not only have the right tool set, but that you have easy access to it.   With web applications, the usual needs are things like running Selenium tests, running unit tests and checking code coverage, profiling, and having links to documentation.  Though I've talked previously about the cost of maintaining 100% code coverage, I'm convinced that it's worth it if you not only get proficient at the tools, but make them very easy to use.  So when I started as the first developer here at Empower Campaigns a couple of months ago, I wanted to make sure these needs were addressed early on, before we had a large development team.


Pragmatic tips for unit testing in PHP

Recently I've been hearing a lot of differing opinions about unit testing.  Some people just don't believe in it at all, others think the value it provides is only part of the picture, and that its cost should be weighed accordingly.  Some think that 100% test coverage should be the goal for high quality software.  I personally think the cost of unit testing 100% of your code is worth it, but only if you can do it efficiently.  And that's the catch; there's a learning curve to become proficient at unit testing, especially with PHPUnit, the most prominent unit testing framework for PHP.  Unit testing should never take more than 20-30% of your overall coding time, if you do it right.