Check for SMW version

if ( version_compare( SMW_VERSION, '1.6 alpha', '<' ) ) { // bc hevaiour here

Installing PDT 2.2 with XDebug 2.1.1 on Eclipse Helios on Ubuntu

(To be improved... got problems with image upload at the moment ... :/ )

After one year of very little PHP / MediaWiki / SMW coding, the time finally has came to get going a bit agian. So first thing was getting a decent PHP IDE with a debugger, up running.

Last year I used Eclipse with PDT (PHP Development Tools) and Xdebug. The installation was a bit tricky though and I had to stay with Eclipse Galileo due to some bugs, but now things have changed. With PDT 2.2 and the latest XDebug (2.1.1), installing on Ubuntu is a snap.

This is what should work:

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:
# 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):
  • 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!

Got Eclipse for PHP up running with XDebug

Got Eclipse for PHP up running now, with XDebug. Yay :) It was a snap to install on my Ubuntu box. I basically followed this and this blog post. (The Ubuntu package for XDebug is php5-xdebug).

The Eclipse dialogs had changed location and structure a little, so for my documentation, I included a screenshot of the dialog under "Run > Debug configurations" below.