Dear Friends,

I have written a small tutorial on debugging drupal and PHP applications with Eclipse PDT and XDebug:

http://programmingbulls.com/debugging-drupal-php--xdebug-eclipse

Kindly, please find it and let me know if it is useful or any correction is required.

Thanks,
Sudeep

--------------------------------------
My site: http://dynamicbrain.net
Dynamicbrain is a religious- spiritual-mental-personal development news site where news articles related to well-being, health, spirituality, religion, self-help, yoga and personal development are regularly posted and even fetched from different web sources. It is an endeavour of "Institute of Psychology and Health".

Comments

gpk’s picture

Hey thanks for this, I was just thinking it is about time I installed a PHP debugger for use on my PC.

For noobs like me it would appear that XAMPP is the same as LAMPP and is available from e.g. sourceforge.net and apachefriends.org.

Fingers crossed it all installs smoothly, and thanks again

sudeoo’s picture

Hey Right. Xampp is same as LAMPP. X stands for platform: could be windows, linux,Mac. Therefore, Xampp becomes Lampp for linux and WAMPP for windows.

Let me know if everything goes well or I can help you in case of any problem.

--------------------------------------
My site: http://dynamicbrain.net
Dynamicbrain is a religious- spiritual-mental-personal development news site where news articles related to well-being, health, spirituality, religion, self-help, yoga and personal development are regularly posted and even fetched from different web sources. It is an endeavour of "Institute of Psychology and Health

amitaibu’s picture

Here's how I did it with the Eclipse PDT all-in-one. I struggled with the Zend debugger, but Xdebug just does the work. Although my WAMP occasionally crashes.
Many thanks to Tao for most of the work he gave in his article!

1. Have a WAMP installed and running.
2. Install PDT
3. Get Xdebug that matches your PHP (the one installed with WAMP)
4. Place XDebug dll in WAMP_path\php\extensions.
5. There is no need to download another plugin for PDT. The XDebug is already implemented there.
6. Add these lines to the php.ini under C:\wamp\Apache2\bin\php.ini

[xdebug]
xdebug.remote_enable=1
xdebug.remote_host="localhost"
xdebug.remote_port=9000
xdebug.remote_handler="dbgp"
zend_extension_ts="C:\wamp\php\ext\php_xdebug-2.0.2-5.2.5.dll"

7. In Wamp restart all services.
8. Open Eclipse.
9. Open your project.
10. Open Debug Dialog> Server debugger = XDebug.
11. PHP Server - create a new one with the http://localhost/ as the root URL
12. Publish the server somewhere on your local disk.
13. Uncheck Auto-generate for the URL, and enter the correct URL as you would enter in your browser.
14. Debug!

btw, I had a problem of memory exhaustion, thus added in the .htaccess this line:

php_value memory_limit 64M

Hope it works for you guys, I know it can be frustrating.
---
gizra.com - where cool software developers meet geek fashion designers

gpk’s picture

Thanks for the info.

There is also quite a bit of info on this site now re. setting up a development environment - in the Handbooks section. This is a good place to start http://drupal.org/node/147786.

@Amitaibu: was any special configuration needed to get WAMP working with Drupal? It would be really useful if you could add a child page with description/instructions here http://drupal.org/node/263

:-)

gpk
----
www.alexoria.co.uk

amitaibu’s picture

Some changes with WAMPServer 2:

Let me try to save you some head banging! :P

..
4. Place XDebug DLL under C:\wamp\bin\php\php5.2.5\ext
..
6. Add these lines to the php.ini (left click on WAMP icon >> PHP >> PHP.ini)

[xdebug]
xdebug.remote_enable=1
xdebug.remote_host="localhost"
xdebug.remote_port=9000
xdebug.remote_handler="dbgp"
zend_extension_ts="C:\wamp\bin\php\php5.2.5\ext\php> php_xdebug-2.0.2-5.2.5.dll "

make sure the zend_extension_ts is directing to the DLL you downloaded, however note I wasn't able to work with this file php_xdebug-2.0.3-5.2.5.dll , so I'm still using php_xdebug-2.0.2-5.2.5.dll

..
12. No need to publish.

Good luck!

---
amitaibu.com

o_bridge’s picture

I got version 2.0.3 to work by using the following line:

zend_extension_ts="C:\wamp\bin\php\php5.2.6\ext\php_xdebug-2.0.3-5.2.5.dll"

I put version 2.0.2 (the link is http://www.xdebug.org/files/php_xdebug-2.0.2-5.2.5.dll, it's not on the web site anymore) and version 2.0.3 side by side in the extensions folder and first pointed to 2.0.2 (php_xdebug-2.0.2-5.2.5.dll) in the line above. When it was working, I changed to 2.0.3 (php_xdebug-2.0.3-5.2.5.dll).

Good luck :)

boaz_r’s picture

Hi,

I've was just referred to this post. I've also written such a guide. Its more detailed and accompanied with screenshots then most other guides I've found on this topic:
http://www.rymland.org/blogs/boaz/5_mar_08/using-pdt-xdebug-for-debuggin...

Boaz.
--
PHP therapist
Linnovate

alex.k@drupal.org’s picture

Just be aware there are two versions of these directives - this article uses zend_extension_ts whereas on my install I need to use zend_extension - try which one works for you

If the debugger extension refuses to show up in phpinfo() output, try setting display_startup_errors = On in php.ini and restarting your webserver - then in webserver's error log you may find some messages if the extension cannot be found, is not the right one, etc. If there are no errors, it's either loading fine (and you should see it in phpinfo()), or php is expecting the other variant of zend_extension / zend_extension_ts

chOP’s picture

If you're using the 'debug' build of PHP, then use the "zend_extension" directive to load the xdebug.dll. If you're using a regular, non-debug build of PHP then use the "zend_extension_ts" directive to load the xdebug.dll. This is the reasoning behind the two variations on extension directives.

If you're unsure which build of PHP you have installed, you can find out by referring to the information returned by:

phpinfo();

Madness takes its toll.
Please have exact change.

--
Madness takes its toll.
Please have exact change.

webkenny’s picture

Subscribing

Kenny S.
Developer by day, entertainer by night.
www.webkenny.com

Proud member of the CommonPlaces E-Solutions team.
www.commonplaces.com

Kenny S.
Follow me on Twitter

pkej’s picture

Paul K Egell-Johnsen

Paul K Egell-Johnsen

webkenny’s picture

An excellent supplement to this is found here as well. I finally got Drupal to debug. Yahoo!

http://www.latenightpc.com/blog/archives/2008/05/24/a-complete-lamp-deve...

Kenny S.
Developer by day, entertainer by night.
www.webkenny.com

Proud member of the CommonPlaces E-Solutions team.
www.commonplaces.com

Kenny S.
Follow me on Twitter

electricmonk’s picture

Hi all,

I've managed to use XDebug successfully in non-Drupal PHP projects. In Drupal, when the 'break at first line' checkbox is checked, the debugger indeed breaks at the first line but then ignores any breakpoints I set. If 'break at first line' is unchecked, the debugger doesn't break at all.

I have set *.module and *.engine as PHP files.

Currently, I manage to work by manually stepping into the code until I get to the line in question, but this is very time consuming. Any ideas?

Environment:
PDT 2.0 (but I also checked using 1.0.3 and same problem occurs)
XDebug version is 2.0.3
Apache is 2.2.8
PHP 5.2.5
XAMPP environment
Windows XP Pro

Thanks

Shai

davidtinnes’s picture

I was able to get debugging working using XDebug Version 2.0.2-5.2.5 instead of 2.0.3

http://www.xdebug.org/files/php_xdebug-2.0.2-5.2.5.dll

Hope that helps
David Tinnes

esend7881’s picture

I want to do debugging only locally, even though my settings.php file points to my remote server.

How do I set up Eclipse PDT so that when I run a debug, it knows to look at my local MYSQL service for the SQL data?

Also, how do I set up XAMPP MySQL service with my .SQL data. My SQL file is about 900 MBs large (although when I gzip it, its 42 Mbs)

Thanks

captaindav’s picture

I posted on another thread but thought I should make a link here:

http://drupal.org/node/259622#comment-2108192

captaindav
http://icfolson.com

timlie’s picture

Sorry for the noob question but I have installed Xdebug and its working.

How do I debug a specific module? Let's say I have a hook_form_alter in one of my modules. I can toggle a breakpoint at this hook. What happen's now is that xdebug is showing you variables and stops at the breakpoint. It only shows me the variables where it is evaluating some alter-forms from the frontpage.

I want to debug where my hook_form_alter is really comming in to place, let's say on a node/add/contenttype page.

How do I achieve this???

Thanx!

anil614sagar’s picture

I have same issue. I solved it. :-) Please insert ?XDEBUG_SESSION_START=ECLIPSE_DBGP&KEY=12581835388283 after your url and insert break points in the code. It will work if you are using eclispe pdt, xdebug.

Cheers,
Anil

Cheers,
Anil Sagar,
Lead Drupal Developer,
Azri Soulutions,
http://azrisolutions.com/

timlie’s picture

Thanx a lot!! This helps :-)

momo18’s picture

I am trying to get xdebug to work (see below) alongside Drupal on a Ubuntu machine. I don't want anything fancy. All I want is to to step through drupal to view the code flow, and inspect the value of variables as I go along.

The first stage was simply to get xdebug to work and show up in phpinfo(). I have searched but I haven't found any clear explanations on how to do this. It appears to me that there's some kind of incompatibility issue going on. I tried both methods. 1) To install xdebug via pecl, as well as to 2) to download the xdebug source and build the xdebug.so manually.

(I also installed eclipse - galileo version successfully, but the application seems to be buggy - and doesn't give me xdebug.)

Has anyone come across this problem? Are there any clear instructions on how to install and try out xdebug on ubuntu. I have successfully installed eclipse, but still haven't gotten to the stage where xdebug will show up as being configured in phpinfo(), when I execute the command http://localhost.

I am using the very latest version of xdebug source code, and so I don't know what the error message to contact... is referring to.

Any ideas on how to resolve this would be appreciated?

Thanks!

CONFIGURING XDEBUG
===================

When I configured xdebug I received the following error message:

PHP API Version 20041225
Zend Module API 20060613
Zend Extension API No. 220060519

PUTTING XDEBUG.SO IN PATH
=========================

In lampp, after adding the following line to php.ini

zend_extension="/usr/local/src/xdebug-2.1.0beta2/modules/xdebug.so

STARTING LAMPP
==============

And executing the following command, I received the following error message:

moses@moses-laptop:/opt/lampp$ sudo ./lampp start
Starting XAMPP for Linux 1.7.3a...
Xdebug requires Zend Engine API version 220060519.
The Zend Engine API version 220090626 which is installed, is newer.
Contact Derick Rethans at http://xdebug.org for a later version of Xdebug.

Xdebug requires Zend Engine API version 220060519.
The Zend Engine API version 220090626 which is installed, is newer.
Contact Derick Rethans at http://xdebug.org for a later version of Xdebug.

XAMPP: Starting Apache with SSL (and PHP5)...
XAMPP: Starting MySQL...
XAMPP: Starting ProFTPD...
XAMPP for Linux started.
cvdenzen’s picture

You did not forget to close the double-quote in php.ini in the line zend_extension="/usr/local/src/xdebug-2.1.0beta2/modules/xdebug.so? I guess you made a mistake with copy-paste.

Carl

man-1982’s picture

A detailed description of the configuration of applications PHPEclipse + DENVER + Xdebug + DRUPAL in Russian language. The level of articles-for beginners. http://man-1982.ru/content/php-eclipse-xdebug-denverdrupal