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:
2. Download XDebug (RC3). If you are working on windows, download it from:
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:
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:
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.