This post was inspired from a post over at 10jumps.com: http://10jumps.com/blog/mac-os-x-eclipse-pdt-xdebug-mamp?page=8.
Any PHP developer knows that it’s not always easy getting debugging setup with Eclipse. I’ve found that it’s gotten easier over the years I’ve been coding in PHP, but it’s still far from painless. The article above describes the settings necessary to configure your php.ini, but I’ll go through all the steps to get debugging setup on your local machine, starting with downloading Eclipse/PDT/MAMP all the way though hitting your first breakpoint.
Step 1 – Download Eclipse
We’ll use Eclipse for JavaScript Web Developers and then install PDT, since as of the Indigo release of Eclipse, there is not a PHP Developer specific version due to a lack of a package maintainer. Just download, extract and place it wherever you’d like. I put it in my Applications folder.
Step 2 – Download MAMP
The current version as of the date of this post is 2.0.1 and can be found here. Extract the downloaded file and run the package installer. By default it will place MAMP in your Applications folder.
Step 3 – Install PDT
In Eclipse, go to Help > Install New Software…
From the “Work with:” dropdown, select the Indigo update site. Then under the “Web, XML, Java EE and OSGI Enterprise Development” section, you’ll find PDT.

Check the box next to PDT and click next. Agree to the license and it should start to install. At the end of the install, a dialog may pop up asking you to restart Eclipse. If so, click “Restart Now”. After Eclipse re-launches, proceed to the next step.
Step 4 – Setup your MAMP server in Eclipse
Next, we’ll tell Eclipse about our MAMP server. In Eclipse, go to Eclipse > Preferences. Then in the box in the top left corner of the preferences screen, type “servers”. This should filter your settings allowing you to see an item labeled “PHP Servers”.

Select “Default PHP Web Server”, then click “Edit”. Set the “Local Web Root” field to the document root of the site you are attempting to debug, then click “OK”. Then click “OK” to close the preferences dialog.
Step 5 – Download the Komodo Xdebug extension
This part is the kicker. The Xdebug extension that ships with MAMP doesn’t always work, but the Komodo one does. Download the Komodo version of the Xdebug extension from the Komodo Remote Debugging Package Downloads page, rename it “komodo_xdebug.so” and place it in the extensions directory for the version of PHP you’re using.
To find out which directory this is, start up MAMP. Once started, it should launch a “Welcome to MAMP” page that gives a link at the top to your PHP info. In your PHP info, you should be able to find an “extension_dir” directive that will tell you the extensions folder that the currently running version of PHP is using.
Step 6 – Edit your php.ini to add the Xdebug configuration
The php.ini that ships with MAMP should have an xdebug section like the one below:
[xdebug]
;zend_extension="/Applications/MAMP/bin/php/php5.3.6/lib/php/extensions/no-debug-non-zts-20090626/xdebug.so"
Find this section and replace it with the following, making sure that the path to komodo_xdebug.so is correct.
[xdebug]
zend_extension="/Applications/MAMP/bin/php/php5.3.6/lib/php/extensions/no-debug-non-zts-20090626/komodo_xdebug.so"
xdebug.profiler_output_dir = "/tmp/xdebug/"
xdebug.profiler_enable = On
xdebug.remote_enable=On
xdebug.remote_host="localhost"
xdebug.remote_port=9000
xdebug.remote_handler="dbgp"
xdebug.idekey=ECLIPSE_DBGP
Step 7 – Make sure your PHP configuration recognizes the Xdebug extension
Restart your Apache server in the MAMP console, then reload the PHP info page in your browser. (This is the same page where you found the extensions directory path). You should now see an Xdebug section in your configuration that looks something like this:

Step 8 – Setup your debug configuration
In Eclipse, go to Run > Debug Configurations… You should see a screen that looks like this:

Select “PHP Web Page”, then click the document with the plus or right click “PHP Web Page” to add a new launch configuration.
Select “XDebug” for the “Server Debugger” option. For the “PHP Server” option, leave “Default PHP Web Server” selected. Browse for the file you wish for the browser to open to when debugging starts. I personally don’t like the script to break at the first line, so you can either uncheck or leave checked the “Break at First Line” option depending on your preference. Leave “Auto Generate” selected. Your configuration should look something like below (obviously with a different value for “File”):

Click Apply, then Close.
Step 9 – Debug something
Add a breakpoint somewhere in your project by clicking in the gray column to the left of your code in one of your PHP files. For the sake of testing your new configuration, I would recommend adding a breakpoint in the same file you selected in your launch configuration.
After you’ve added your breakpoint, click Run > Debug Configurations… Then select your newly created configuration and click the “Debug” button. Eclipse should launch your browser at the URL you specified in your launch configuration (with a few additional parameters that allow XDebug to work) and stop at your breakpoint.