Bookmark and Share

Remote debugging PHP using Xdebug on MAMP

Posted: Thursday, May 21st, 2009 at 10:19 pmUpdated: Thursday, May 28th, 2009 at 5:38 pm

A development tools such as Microsoft Visual Studio has debugging feature built-in where you can step through the code line by line and watch the variables. There are times when you may want to do the same thing with PHP script running in a remote (or it could be local as well) web server. It is possible thanks to Xdebug.

This article will focus on configuring Xdebug on your MAMP development platform. We’ll focus on utilizing Eclipse IDE platform as debugger client. So let’s get started.

Installing Xdebug on your MAMP

In my previous article on setting up MAMP, I mentioned there are 2 ways you can have MAMP on your Mac. If you want to get really picky, there are 3, including Rebuilding MAMP stack from scratch..

Regardless which way your MAMP is configured, the easiest and quickest way, perhaps, is to download Xdebug binary that I compiled myself. Note that it was compiled on Intel Mac on 10.5.6 Leopard and was tested only on my Intel MacBook Pro.

So which version to use? Well, Xdebug documentation recommends version 2.0.2, but then again, I’m not sure how outdated the documentation is. So I decided to provide all and let you decide yourself.

If you’re using MAMP Application package

Once you decide which version to download, copy the newly downloaded to /Applications/MAMP/bin/php5/lib/php/extensions/no-debug-non-zts-20050922/. Your extension location may vary depending on which MAMP version you have installed. Check phpinfo() page for your exact location.

Xdebug is not compatible with Zend Optimizer. So you need to make sure that Zend Optimizer is disabled in your MAMP. Click on preferences button then on PHP section, make sure Zend Optimizer is unchecked. Also make sure that you’re not using cache. Below is how your PHP MAMP preference should be.

Then edit your php.ini using your favorite text editor. For my MAMP installation (version 1.7.2), php.ini is /Applications/MAMP/conf/php5/php.ini. Then add the following line somewhere in your php.ini. I like to add it at the end of the file.


Make sure you specify the absolute path to xdebug binary otherwise you may have some issues. Save your modified php.ini file and restart servers on MAMP app. Then go to phpinfo() page again and make sure that Xdebug is listed.

If you’re using the built-in PHP

The concept is basically very similar to the MAMP app. The only difference is the location of php.ini file, extension_dir and how to restart Apache. On the built-in MAMP stack, restart Apache from System Preferences -> Sharing then check & uncheck Web Sharing service.

Next, we’ll discuss on using Xdebug for remote debugging using Eclipse IDE through example.

Pages: 1 2 3 4

2 Responses to “Remote debugging PHP using Xdebug on MAMP”

  1. Javin @ FIX Protocol Tutorial Says:

    Nice article , In my opinion Remote Debugging is the single most feature which convinced me to migrate from Netbeans to Eclipse.

    How to setup remote debugging in Eclipse

  2. Zholeh Says:

    Hi, I had the same problem with the vabiarles view being opened causing the debugger to fail with the cryptic message. I fixed it in a very strange way:1) I changed the xdebug module from the default that came with xampp (1.7.4) with php_xdebug-2.1.0-5.3-vc6.dll.2) I also made sure that the path for xdebug in php.ini was relative instead of absolute: zend_extension = \xampp\php\ext\php_xdebug-2.1.0-5.3-vc6.dll;These two things took me from frustrated axe murderer to prancing unicorn. I’m to scared to mess about with it to determine if it was just the module change or the php.ini change. Hope this helps someone.

Leave a Reply