What debugger is used to debug Drupal?

Since I’m working on module development and deals with so many websites during my projects, I found Xdebug is a great tool to debug Drupal modules. I am listing here step by step process to debug drupal using xdebug and Eclipse with your WAMP.

Download Eclipse PDT from here http://www.eclipse.org/downloads/download.php?file=/technology/epp/downloads/release/…

Download php_xdebug-2.0.4-5.2.8.dll dll and place in C:\wamp\bin\php5.2.6\ext directory

Edit your php.ini file with the following code at the end of file.
[xdebug]
zend_extension_ts=”C:\wamp\bin\php5.2.6\ext\php_xdebug-2.0.4-5.2.8.dll”
xdebug.remote_enable=1
xdebug.remote_host=”localhost”
xdebug.remote_port=9000
xdebug.remote_handler=”dbgp”

Note: Carefully check the path and PHP version you’re using on zend_extension_ts line above.

Restart WAMP server.

If it’s successful installation of xdebug, when you view phpinfo.php, you will find the lines below:

Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies
with Xdebug v2.0.4, Copyright (c) 2002-2008, by Derick Rethans

Open your Eclipse and add the drupal folder as php project. Todo this just create an emty php project and give the project workspace as c://wamp/www and add import your existing drupal folder to this project as a general folder import in eclipse.

Open Window->Preferences->General->Web Browser and set your browser as external browser and select any of your browser.

Then go to Window->Preferences->PHP->Debug, set PHP Debugger option to XDebug

Next select your index.php -> right click -> Debug as -> Php webpage. Now your defined browser will open and you can see your project is running.

Now go to Window -> open Perspective -> PHP debug. You can see code is halted at first line of code. If you press play button in green color, your codes will execute.

Set break points wherever you want in the files and click on step into to see the code flows.

To make module files open in Eclipse, you must add extensions to *.module to window->preferences->general->editors->file associations file type such as *.module, *.engine, *.inc and associated editor as PHP

Please leave a comment for this article if you encounter any issue during the installation and debugging. I hope that this article helps you.