Simple step-through PHP debugging on a Mac with XAMPP, XDebug and MacGDBp

Simple step-through PHP debugging on a Mac with XAMPP, XDebug and MacGDBp

Posted 11/23/2009 - 15:18 by State68

Earlier this year I needed to make a bit of money so I developed a database app in Filemaker. In many ways I found it a real pain to use - selecting each line of the code you want to write from a clickable list is far from ideal - but its limitations meant that debugging was really straightforward: use the built-in step-through debugger, follow everything through, find the bug, fix it.

Going back to Drupal and PHP development after using Filemaker was great in terms of speed, efficiency and flexibility, but I really missed that step-through debugging. I knew that this was available in weighty IDEs like Eclipse, but I'm a big fan of TextMate and wanted to stay with it.

Then I found MacGDBp. It's a very simple step-through PHP debugger that works on any Mac running OS X 10.5+ that has XDebug installed. Here's how to use it with XAMPP, my favourite server-in-a-box:

  1. Download and install XAMPP. Note that this is XAMPP version 1.0.1, the last version of XAMPP - as far as I know - that used PHP 5.2.9. Later versions use PHP 5.3, which is not yet compatible with Drupal.
  2. Download the latest XDebug binaries from here. You need the Mac OS X version of the PHP Remote Debugging package.
  3. Decompress the XDebug binaries. You'll end up with a folder called something "like Komodo-PHPRemoteDebugging-5.2.2-35694-macosx". In that folder there are a few subfolders; pick the subfolder that corresponds to the version of PHP you are going to be running - 5.2 if you've installed XAMPP 1.0.1.
  4. In that folder there is a file called xdebug.so. This needs to be copied to your XAMPP extensions folder, which will be somewhere like /Applications/XAMPP/xamppfiles/lib/php/php-5.2.9/extensions/no-debug-non-zts-20060613.
  5. Now you need to tell XAMPP that the XDebug extension has been installed. To do this, edit php.ini which should be in /Applications/XAMPP/etc. Add the following lines to the bottom of the file:
    [xdebug]
    zend_extension=/Applications/XAMPP/xamppfiles/lib/php/php-5.2.9/extensions/no-debug-non-zts-20060613/xdebug.so
    xdebug.file_link_format="txmt://open?url=file://%f&line=%1"
    xdebug.remote_enable = On
    xdebug.remote_autostart = 1

    You might have to fine-tune this to get the paths absolutely right.
  6. Download and install MacGDBp from here.
  7. You're good to go: run MacGDBp, and then load any PHP file that's on your XAMPP server - MacGDBP will step through it, and let you set breakpoints.
Super!

This totally worked.... I can't believe it worked!!!!!

Thanks ;-)

Posted by Anonymous on Sun, 04/21/2013 - 02:13
Simple step-through PHP debugging on a Mac with XAMPP, XDebug an

Thx very very much !!

Posted by Anonymous on Thu, 04/07/2011 - 08:28
:)

Short, sweet, and accurate instructions. Up and running with no troubles. Thank you for saving my sanity.

Posted by Anonymous on Tue, 03/01/2011 - 20:35
Sure does work for XAMPP and Netbeans!

Great, thanks State68!

Posted by Anonymous on Mon, 01/03/2011 - 21:12
Ummm ... AWESOME!

I've been searching for DAYS for how to install Xdebug on OS X to use with XAMPP. This tutorial worked!!! Thank you thank you thank you! Finally I can debug with Xdebug!

Posted by Anonymous on Fri, 11/19/2010 - 20:15
Great info, thank you!

BTW, this also works for Netbeans, just don't take into account the info related to "MacGDBp"

Posted by Anonymous on Sun, 01/31/2010 - 05:06