Remote PHP Debugging on Intel-based Macs with Komodo

I got a new computer. Yay! It's a Mac Pro.

So naturally I want to set up my Drupal working environment on it.

However, I use the Zend IDE and the Zend Studio Server debugger will not run on Intel-based Macs. No, seriously. It's inexcusable.

I love my real-time debugging. So I decided to try out Komodo. I've made a point to ask about OS X versions of Komodo at the ActiveState booth for as long as I've been attending OSCON. Now they've got a stable version and it supports Macintel.

Well, almost.

So, starting with my new Mac Pro, I installed XCode Tools to get cvs and all the other command-line niceties. Then I headed off to Marc Liyanage's PHP page to install PHP (even PHP treats Marc's installer as the official binary).

PHP 5 installed fine, but I got this unusual hiccup when starting Apache:

[warn] module mod_php5.c is already added, skipping

Commenting out the line

AddModule  mod_php5.c

from /etc/httpd/users/+entropy-php.conf got rid of the warning. I'm guessing that Apache is somehow automatically doing an AddModule when it hits the LoadModule line. Anyway, it works fine.

Next, it was time to set up Komodo for debugging. First I wanted to make sure it found the php5 that I installed, and not Apple's php4. So I did this in /etc/profile:


and then moved Apple's php binaries out of the namespace:

sudo bash
cd /usr/bin
mv php php-old
mv php-config php-config-old
mv phpize phpize-old

I logged out and back in to activate the new PATH and tested:

which php

I put this


into /Library/WebServer/Documents/phpinfo.php and sure enough, http://localhost showed me the PHP info page. Good so far. On to installing Komodo.

I downloaded Komodo, copied it to Applications, and clicked on it.
Chose Trial version
Got email with URL for evaluation activation key.
Double-clicked to get ActiveState License Installer.
Double-clicked to install license.

Now I started Komodo. I built the "intelligence database" and set up Langugages - PHP.

Now it was time to set up debugging. I used Languages - PHP - Debugger config wizard to put the debugger's php.ini file into ~/komodo/ini and the debug extension into ~/komodo/extensions. It then informed me that the debugger extension could not be started. I did this many times.

Finally, I got annoyed with the debugger config wizard. Instead, I installed xdebug myself. Here's how. First download xdebug (I downloaded version 2.0.0beta6). Then compile it:

cd xdebug-2.x.x
./configure --enable-xdebug
mkdir /usr/local/xdebug
cp modules/ /usr/local/xdebug/

Then I edited /usr/local/php5/lib/php.ini to include the following:


While I was editing php.ini anyway, I changed memory_limit to a sane number.

Applied my changes by restarting Apache:

apachectl restart

Next I configured Komodo to listen for xdebug by going to Preferences - Debugger - Proxy. I set Listen for debug connections on port: to 9000.

Then I went to the Debug menu and chose Listen for Remote Debugger.

And, when I went to http://localhost/phpinfo.php in my browser...wah la! Nothing happened. But when I added the xdebug parameter, like this:


then Komodo was invoked and I could step through the request, just like in Zend. Whee!

Note: I have confirmed that that is included with Komodo, which Komodo helpfully installs in whichever directory you specify during your time with the Debugger Config Wizard, does not work. That file has an MD5 of 8cca2df563529f950219a86cfadf2e48.

However, the version of I compiled does work.

This writeup dedicated to webchick, who allegedly has lost a good two weeks of her life dealing with remote debugging on Macintel.

P.S. I've tried this with MAMP 1.3.1 and it works fine. Also, it doesn't seem to matter which value I use for xdebug.idekey. Also, if you want to request some pages without the debugger firing up, turn off the Listener under Debug - Listen for Remote Debugger.

Helpful references:

Komodo 3.5 Debugging Documentation
Debugging Drupal with Activestate Komodo
xdebug documentation