Remote PHP Debugging Using Eclipse

Events happening in the community are now at Drupal community events on www.drupal.org.
Summitt Dweller's picture

I would like to be able to debug (walk through) some PHP/Drupal code (specifically some Islandora contributed modules) to try and solve some apparent configuration problems (and just to get better acquainted with the inner workings of the system). I've got Eclipse with PDT setup on my Windows 7 system, and wish to conduct some remote debugging of code that lives on an Ubuntu 10.04 virtual 'test' server. There appears to be a lot of good remote debug configuration info available (perhaps too much to sift through) on the web, but I haven't found any that's specific to my environment yet.

I'm just wondering if anyone in this community has been down this road, or a similar path, before? Any experience/advice/guidance/wisdom you can offer would be greatly appreciated. Thanks in advance and take care.

Mark

Comments

eclipse & xdebug

heddn's picture

Here's the contents of my xdebug.ini. Or you can add it directly to your php.ini

zend_extension=/usr/lib/php5/20090626/xdebug.so
xdebug.idekey=default
xdebug.remote_enable=on
xdebug.remote_handler=dbgp
xdebug.remote_host=localhost
xdebug.remote_port=9000

Eclipse setup:
Preferences => PHP => Debug => Installed debuggers => xdebug
Accept remote session (JIT): any

Preferences => PHP => PHP Servers
Server tab
Base url: http://www.example.com
Local web root: c:\www.example.com (must have code checked locally on the windows 7 server)

Here's a bookmarklet to start debugging: javascript:(function(){location.href=location.href+'?XDEBUG_SESSION_START=default';})();

Here's a bookmarklet to stop debugging: javascript:(function(){var currentUrl=location.href;var gotoUrl=currentUrl.replace('?XDEBUG_SESSION_START=default','');document.cookie='XDEBUG_SESSION=default;expires=Fri, 3 Aug 2001 20:47:11 UTC;host=none;path=/';location.href=gotoUrl;})();

Just copy these into a new bookmark in your browser and when you select them, it will start/stop debugging in eclipse for the website you are visiting.

An additional resource: http://www.cleancode.co.nz/blog/724/remote-php-debugging-eclipse-php-xdebug

Central Iowa Drupal Users Group

Group categories

Category

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: