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:

  • Get yourself an Eclipse version.
  • Go Help > Install new software
  • Add the following update site URL: http://download.eclipse.org/tools/pdt/updates/2.2/milestones (The main helios site contains a bug! ... this is mentioned somewhere, but can't remember where ...)
  • Click through the wizard and install the PDT packages.
  • Get the XDebug 2.1.1 source
  • Unpack it, enter the created folder, and (according to the README) run:
  • phpize
  • ./configure --enable-xdebug
  • make
  • cp modules/xdebug.so [to wherever you want it]
  • Add to the end of your php.ini, or a dedicated xdebug.ini file (I have a suh in /etc/php5/apache2/conf.d/xdebug.ini) (here, some more settings are included than what the README says):

    zend_extension=/usr/lib/php5/20090626+lfs/xdebug.so
    xdebug.remote_enable=1
    xdebug.remote_host="localhost"
    xdebug.remote_port=9000
    xdebug.remote_handler="dbgp"
  • sudo service apache2 restart
  • Write a php page that calls phpinfo();, fire the page up in a web browser, and look for a mention of xdebug.
  • Start Eclipse
  • In Windows > Preferences > Debug, make sure that "XDebug" is selected as PHP Debugger.
  • Create a new PHP project.

  • Create a new PHP file.

  • Write some code, and add a breakpoint somewhere.
  • Click the Debug button > Debug as > PHP Web page

  • Be careful! Now you'll see a dialog where you can enter the URL path to the file. In order to have it show up in your web browser, you might need to link the source folder in the eclipse workspace to your /var/www folder, like:

    ln -s /home/samuel/eclipse-workspaces/php/PHPTest/ /var/www/phptest

    (If you fail to configure this correctly, you can edit it by going: Debug button > Debug configurations > PHP Web Page > [Your actual configuration], then there is a field "URL", where you need to uncheck the "Auto generate" checkbox, and configure the URL correctly. See screenshot:

    [Screenshot to be uploaded]

  • Now the debugger should start, and stop at your breakpoint.
Tags: