Debugging Drupal or any PHP Application with XDebug and Eclipse PDT



I have been coding in PHP and MYSQL using my favourite LAMPP for a long time now using VIM. And with the growing complexity of sysytems, it was becoming increasing difficult to keep up with VIM. I was working on Drupal and was writing, debugging few modules. I needed a debugger badly and then I stumbled upon Ecipse PDT. It took a while to set up, but once it was up, it was a power tool that I probably should have gotten earlier.

Eclipse Perl plugin too is cool and use it often to debug perl applications. Eclipse PHP plugin is known as PHP Development Tool (PDT).

Step by step procedure to the set up of eclipse PDT and using it with LAMPP as follows. Later I would also explain how to use Drupal with Eclipse PDT.

1. Download PDT RC3 All-in-One package for your platform from following link:

http://download.eclipse.org/tools/pdt/downloads/?release=S20070401-RC3

2. Download XDebug (RC3). If you are working on windows, download it from:

http://xdebug.org/link.php?url=xdebug200rc3-512-win

3. Put the XDebug.dll in C:/xampp/php/extensions.

4. Configure your php.ini by putting following lines at the end and comment out current existing zend_extension_ts:

[xdebug]
xdebug.remote_enable=1
xdebug.remote_host="localhost"
xdebug.remote_port=9000
xdebug.remote_handler="dbgp"
zend_extension_ts="C:\xampp\php\extensions\php_xdebug.dll"

For your information, I am using xampp version 1.6.1 with Apache 2.2.4, Mysql 5.0.37, PHP 5.2.1 + PHP 4.4.6

5. Start your apache and check using php -m that XDebug module is loaded under Zend.

If successful, you have successfully installed Xdebug in your Xampp.

6. Now, download XDebug moudlue from:

https://bugs.eclipse.org/bugs/attachment.cgi?id=66656

7. Copy this plugin to eclipse plugin directory.

Voila!! Start Eclipse. Everything is set up. Now you should be able to use Eclipse PDT to debug your applications (and maybe,Drupal as well).

8. Eclipse would ask for workspace when it would start. Point it to xampp htdocs directory. For me, it is C:/xampp/htdocs.

9. After it is started, you can start a new project or load a new one. See eclipse document for more details.

10. Once is is done. Click Debug. A window would open. Double click on new configuration "PHP Script with XDebug. Now, enter the URL that should load which you want to debug and the script. Click Debug and your debugger should work.

11. For Drupal to work, you would need to associate .module, .theme, .engine files with PHP. This can be done using: Window->Prefrences->General->Content Types->Text->PHP Content Type.

Now, add *.engine, *.install, *.module, *.theme to this. Eclipse would now recognize all your drupal files and you should be able to debug them.

 

 



Newer version of PHP does not work with this. See http://munim.tumblr.com/post/917355998/how-to-setup-xdebug-on-xampp-and-eclipse

It's been really awesome to have read great writing from you! I'm hoping to read more well written articles such as this!

I started debugging/start the drupal from install.php. But all it goes is till the update.php and not furthur.
Whereas I need to start te debugging in the administer page.
I have put so much time looking through the coding also to catch the correct page but in vain.
Can you help? Thanks in anticipation.