PHP Debugging with Eclipse and XDebug

From StutsmanSoft Developer Wiki

Jump to: navigation, search

Debugging is one of the first things I missed when transitioning to PHP. But guess what, you can debug PHP - it's just not enabled by default.

You need two things:

  1. XDebug
  2. Eclipse or MacGDBp

XDebug

XDebug is a module for PHP that you'll need to download and build from source.

  • Download the source:
svn co svn://svn.xdebug.org/svn/xdebug/xdebug/trunk xdebug
  • Build it:
./rebuild.sh
  • Copy it to the PHP Extensions directory
sudo cp modules/xdebug.so /usr/lib/php/extensions/xdebug.so
  • Edit /etc/php.ini

Add the following:

[xdebug]
zend_extension=/usr/lib/php/extensions/xdebug.so
xdebug.remote_enable = On
xdebug.remote_autostart = 1
  • Restart Apache
sudo apachectl restart

Setup Eclipse

Download Eclipse for PHP Developers: [1]