I am a Permanent Member (or Community Ambassador) of the Drupal Association.The Acquia Drupal Stack installer for Mac OS X 10.6 (Snow Leopard) has been released, and it’s pretty cool (works on 10.5 Leopard, too, of course). I’m now using it as my primary development environment, replacing MAMP. In this article I show how you can configure the stack installer to use XDebug for step through debugging. I do so using Komodo IDE, but the steps I follow will help you with Eclipse or any other IDE that supports XDebug. I also install a Firefox plugin called XDebug Helper that makes the whole debugging experience smoothe and sweet.
Once you have the stack installer and Komodo IDE installed, the next step is to get a copy of the xdebug.so file that comes with Komodo, and make it available to the PHP binary in the stack installer. I opened up Terminal and executed these commands:
cd /Applications/acquia-drupal/php/bin
cp /Applications/Komodo\ IDE.app/Contents/SharedSupport/php/debugging/5.2/xdebug.so .This copies the 5.2 version of the xdebug.so into the same directory as the php binary. While I was there I used vi to edit the php.ini file. You can use any editor you care to - the file, by default, should be found at
/Applications/acquia-drupal/php/bin/php.iniAdd these lines to the bottom of the file:
[debug]
; Remote settings
zend_extension=/Applications/acquia-drupal/php/bin/xdebug.so
xdebug.remote_autostart=off
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_host=localhost
xdebug.remote_port=9000Now you need to stop and start the stack using the Acquia Drupal Control Panel. You can check to see if XDebug is loading properly by going to Settings > Config, also in the control panel. Click the phpinfo link, and in the page that opens in your browser, look for the XDebug section.


Make sure Komodo is prepared to accept incoming debug connections. You then can set a breakpoint in Komodo at a place in the code you want to inspect further.
.jpg)
Test it all out by appending &XDEBUG_SESSION_START to your site’s URL:
http://localhost:8082/acquia-drupal/?XDEBUG_SESSION_START
If all is working correctly the Komodo icon will start bouncing in the dock and you’ll see that the program execution has stopped where you set the breakpoint. You can now do cool things like look at the values of variables, step through one line at a time, set conditional breakpoints, and change the values of variables in scope manually. This is a great way to get to know how Drupal works, by the way.
-1.jpg)
Finally, to make it a bit easier to start debugging sessions, I installed the XDebug Helper Firefox plugin. Now I have a nice looking “X” at the bottom of Firefox. If it is grey, no debugging will happen. If I click it and it is green, the next page load will trigger debugging (assuming I have a breakpoint set). Now my development environment rocks and I don’t have any more excuses for not writing mountains of cool code. Have fun!

Comments
Awesome!
Thanks for the post, I’ve pointed at this from here:
http://www.openkomodo.com/blogs/jeffg/debugging-komodo-and-acquia-stack
There seem to be a lot of people in the community using Komodo for Drupal development - the easier it is for them to get up and running with debugging the better.
cheers, Jeff
Time to move on from MAMP
Looks like it’s time to ditch MAMP in favour of the Acquia stack.
People who are interested in doing step through debugging on Ubuntu can follow this guide to get started: http://ratatosk.backpackit.com/pub/1842524-drupal-on-ubuntu
Windows?
How do we get this working with the Windows version of DAMP, Komodo and XDebug?
Komodo doesn't seem to like the php exe bundled with the DAMP installer.
Thanks in advance.
Port Correction
Great article Rob.
I got everything to work splendidly after I changed the xdebug.remote_port=9000 in php.ini to port 55212. It seems in my installation of Komodo, this was the standard Host port for Debugger listening.
After I changed the port setting, it worked like a charm!
Port Setting
In your Komodo->Preferences->Debugger->Connection, you must make sure 'a specific port' is selected and that it reads port 9000. Save your settings.
The other option, 'a system free port' will use a different port every time.
MAMP PRO differences
Thanks so much Rob, these instructions worked fine for MAMP Pro.
The differences:
-- In MAMP pro you edit the php.ini file from File->EditTemplate
-- In php.ini, I replaced the "9000" port with the one that is shown when you go to Debug->ListenerStatus in Komodo.
Post new comment