Sunday, May 31, 2009

PHP-Eclipse PDT Debugging with Xdebug and Zend

Debugging with Xdebug and Zend
------------------------------
1. It's one of longest learning exercise almost took two full days to understand the very concept of debugging Eclipse based IDE applications.

2. Debugging in PHP is Clint/Server based. Extension of xdebug, zend debuggers added as module with PHP. These debuggers has the ability to stop, start and control the process flow in PHP execution...! and acts as debug server.

3. Clients could be any front end IDE such as Eclipse PDT which can listen for debuggers in port 9000 (Xdebug), port 10000 (Zend) for incoming debug initiation communication from remote Debug servers.

4. Debug communication in Xdebug as per DBGp protocol.

5. Pre-Requisites
(a) Download XAMPP from http://www.apachefriends.org/en/xampp.html for Apache, PHP, MySQL, PHPMyAdmin
(b) Download Eclipse PDT from http://www.eclipse.org/pdt/downloads/
(c) Install XAMPP in "c:\xampp" location
(d) Add Apache virtual directories for my outside working directories
(i)
Alias /working "C:/EclipsePulse/Working"

Order allow,deny
Allow from all



6. Xdebug
(a) Edit PHP.INI file
(i) Comment all in [zend] configuration
(ii) uncomment in [xdebug] configuration
- xdebug.remote_enable=true
- xdebug.remote_host="localhost"
- xdebug.remote_port=9000
- xdebug.remote_handler=dbgp
- zend_extension_ts="C:\xampp\php\ext\php_xdebug.dll"
(b) Restart Apache
(c) Start Eclipse PDT
(d) Configure and create new "Debug Configurations" from Run->Debug Configurations..->PHP WebPage and select Xdebugger option.
(d) After writing simple PHP script, run the webpage using "Debug As..." menu.
(e) Debug run brings PHP Debug perspective views and debug starts....!!!!!

7. I am not able to exactly understand Zend debugger required components.

8. Finally, downloaded 'Zend Server Community Edition' from www.zend.com/community. It contains Apache, PHP preconfigured to run Zend debugger. Zend Server Community Edition is roughly equivalent to XAMPP package.

9. Setting similar to Xdebug except, i started Zend Server. Steps as following:
(a) Start Apache
(b) Start Eclipse PDT
(c) Configure and create new "Debug Configurations" from Run->Debug Configurations..->PHP WebPage and select Xdebugger option.
(d) After writing simple PHP script, run the webpage using "Debug As..." menu.
(e) Debug run brings PHP Debug perspective views and debug starts....!!!!!

10. Disabled Apache-Zend services to enable Xdebug using c:\xampp\eclipse\eclipse.exe

11. Above notes are not exhaustive, but gives rough idea about installation of Eclipse PDT setup.