Debugging MediaWiki extensions with Eclipse for PHP and XDebug on Ubuntu 10.04

 I ran into some troubles with the debugging with XDebug in Eclipse for PHP Developers / PDT (breakpoints stopped to take / catch, after I changed location of my www folder - which I figured out later), so I wanted to document the full setup procedure it here. I mainly followed this blog post. (Assuming you have apache and php set up!).

  • Download Eclipse for PHP developers
    • I'm using the Linux 32 bit version
    • Because of a bug with PDT for Eclipse Helios, I chose to go with Eclipse PDT SR2 for now.
  • Install XDebug by typing:
 apt-get install php5-xdebug
  • Edit /etc/php5/conf.d/xdebug.ini to look something like this:
 zend_extension=/usr/lib/php5/20090626+lfs/xdebug.so
xdebug.remote_enable=On
xdebug.remote_host="localhost"
xdebug.remote_port=9000
xdebug.remote_handler="dbgp"
# xdebug.remote_log="/tmp/xdebug.log" 
    • The log line can be good to enable in case you run into troubles.
    • The first line can be different depending on PHP version. Use the line that you can find in the file (which is the default for your version of Ubuntu):
 /etc/php5/conf.d/xdebug.ini.ucf-dist
  • Restart apache:
 sudo apache2ctl restart

Configure Eclipse

  • Create a PHP Project. Mine is named "RDF4SMW".
  • Choose Run > Debug Configurations in Eclipse
  • Turn the configuration to your web server setup. For me, it looks like this ("smw" is the folder where MediaWiki is installed):

Custom location of www folder

Then an important thing If you have changed the location of your www folder from /var/www, then don't miss this! This was what caused the problem for me, with breakpoints not taking:

  • Click the "Configure" button in the Debug configuration screen seen above
  • Click the "Path mapping" tab
  • Configure according to the location of your www folder. My current config looks like so:
  • This should be it. Happy debugging!

Comments

Use XDebug v 2.1.0

Well, I ran into troubles anyway. The value of local variables was not shown. This was solved by downloading (from here) and compiling the latest version of XDebug (2.1.0) from source. Step by step instructions:

 apd-get install php5-dev

 cd [xdebug source dir]

 ./configure --enable-xdebug

 /usr/bin/phpize5

 make

 cp modules/xdebug.so [your-wished-folder]/

Then change the first line in /etc/php5/conf.d/xdebug.ini to the path of [your-wished-folder]/xdebug.so