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

Now that we verify that Xdebug is properly installed in our MAMP stack, let’s configure it for remote debugging. Edit your php.ini again and add the following configuration options. Save the modified php.ini and restart your Apache server.

xdebug.remote_enable   = On
xdebug.remote_host     = "localhost"
xdebug.remote_port     = 9000
xdebug.remote_handler  = "dbgp"
xdebug.profiler_enable = On

Since we’ll be using Eclipse IDE, we better have Eclipse installed with PHP support. Please visit Eclipse PDT site to install Eclipse and configure PHP support. From this point on, I’ll assume you have Eclipse working with PHP development support.

Using Eclipse IDE for PHP remote debugging

The best tutorial, I think is by example. In this tutorial, we’ll start from creating a project to writing and start debugging. So once Eclipse IDE is opened, click on File -> New -> PHP Project. Since I’m using MAMP app, I’m setting the project location to /Applications/MAMP/htdocs. Click finish button.

Now, making sure eclipse remote debugging tutorial project selected, create new PHP file by clicking on File -> New -> PHP File. Name the file as test_debug.php. Click on finish button.

Then type in the following PHP code and save test_debug.php.

function divide($num, $divisor) {
	if (($divisor % 2) == 0) {
		return 0;
	$ret_val = $num / $divisor;
	return $ret_val;

for ($i = 0; $i < 5; $i++) {
	$divided = divide($i + 3, $i);
	echo "Iteration $i divided is $divided <br />";


And the expected result if you run the script above is as follows:

Next, we’ll prepare Eclipse IDE for remote debugging.

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

Time limit is exhausted. Please reload the CAPTCHA.