« Back to blog

Blog: Compiling Xdebug on OSX (v2.1.0beta1)

Graham Weldon

11 January, 2010

Xdebug is essential. If I was a superhero, and had a utility belt, Xdebug would have a spot on there for sure.

In developing for CakePHP, and any PHP applications in general, Xdebug allows me to extend the basic error reporting of PHP to provide much more helpful information, as well as a host of other features that I'll explain briefly here.

I've just compiled and enabled the latest Xdebug 2.1.0beta1 available from the Xdebug website and it couldn't have been simpler:

  1. Download source
  2. Extract source compressed file
  3. Run: phpize
  4. Run: configure --enable-xdebug
  5. Run: make
  6. Copy modules/xdebug.so to somewhere useful for PHP to access it
  7. Change/Add the 'zend_extension' directive in php.ini to point to the copied file location
  8. Restart Apache
  9. Profit! .. or more precisely, Debug!

Okay, so after writing that list, it seems like a long process, but seriously, this took under 2 minutes, and I was up and running with the latest Xdebug version, and subsequently, able to flawlessly check code coverage on the upcoming CakePHP 1.3 core test cases without Segfaulting all over the shop.

So what is Xdebug?

You can read all about its features on their website, but here is a rundown. It enables better stack traces in the event there is an error with your application. It is capable of monitoring memory allocation to enable memory profiling and performance tuning of your app. Protection against infinite loops and recursion (trust me, a godsend!).

Most importantly for me is the remote debugging capabilities, the memory profiling (facilitated by Webgrind, and the code coverage analysis. These tools allow me to successfully deploy working, tested, checked and stable code with confidence.

Thanks Xdebug! 2.1.0 beta is looking very promising!

Comments