Eclipse Debug





Setup Eclipse Debugger

Know where the php.ini and PHP extensions directory is. (/etc/php5/apache2/php.ini)
Make a simple phpinfo.php where it only contains <?php phpinfo(); ?>
you can also get php info by installing the package php5-cli in linux

Run the server and check the content of that page you made - it will include all info about your local PHP
OR
$ php -i | grep "Loaded Conf"

Download eclipse PDT
Download Zend Debugger
Either from
    http://downloads.zend.com/pdt/server-debugger/
OR
    http://www.zend.com/en/products/studio/downloads  -- Studio Web Debugger -- for windows
OR
    Zend Community Edition (we only need the ZendDebugger.so from the whole package!)
Move ZendDebugger.so (or ZendDebugger.dll) to extension_dir of the php core configurations mentioned in the phpinfo.php you made.
/usr/lib/php5/20060613+lfs   OR c:/wamp/bin/php/php5.3.4/ext/
OR
$ php -i | grep "exten"

Modify php.ini (found at Configuration File (php.ini) Path mentioned in the phpinfo.php you made.) as following:
[Zend]
zend_extension="/full/path/to/ZendDebugger.so"
zend_debugger.allow_hosts="127.0.0.1, 10.0.1.3"
zend_debugger.expose_remotely=always

Check if the module installed correctly
refresh the phpinfo.php you made and see if the result includes Zend Debugger
or by $ php --php-ini /etc/php5/apache2/php.ini -m
[Zend Modules]
Zend Debugger
put your projects at the home directory of the web server, give eclipse the path of the particular file you are executing on the server, and debug!

Xdebug

To use Xdebug in linux you have to get the source code of Xdebug
To compile Xdebug we need php5-dev 
$ sudo apt-get install php5-dev
Perform the steps at the README file in the unzipped Xdebug source code directory to compile it
$ cd xdebug_source_code_dir
$ phpize
$ ./configure --enable-xdebug
$ make
$ make test
$ cp xdebug.so /usr/lib/php5/20060613+lfs    (the extension_dir of PHP, obtained through the php functioncall of phpinfo();)

add the following to your php.ini (mine was in /etc/php5/apache2)
zend_extension="/usr/lib/php5/20060613+lfs/xdebug.so"
xdebug.remote_enable=On
xdebug.remote_host="localhost"
xdebug.remote_port=9000
xdebug.remote_handler="dbgp"
 Other WORKED! way:
Go to http://www.xdebug.org/download.php click on custom installation instructions. It tells you which Xdebug to download and what to do
  1. Download php_xdebug-2.1.1-5.3-vc9-x86_64.dll
  2. Move the downloaded file to c:\wamp\bin\php\php5.3.4\ext
  3. Edit C:\wamp\bin\apache\Apache2.2.17\bin\php.ini and add the line
    zend_extension = c:\wamp\bin\php\php5.3.4\ext\php_xdebug-2.1.1-5.3-vc9-x86_64.dll
  4. Restart the webserver   (you might have to change xdebug.remote_enable = on)
My php.ini had the following lines:
zend_extension = c:\wamp\bin\php\php5.3.4\ext\php_xdebug-2.1.1-5.3-vc9-x86_64.dll
xdebug.remote_enable=true
xdebug.remote_host=127.0.0.1 
; if debugging on remote server,
                              ; put client IP here
xdebug.remote_port=9000
xdebug.remote_handler=dbgp
xdebug.profiler_enable=0
xdebug.profiler_output_dir="c:/wamp/tmp"

In eclipse   Window->Preferences->PHP->Debug   select Xdebug instead of Zend
click Debug Configurations->Server Debugger->Xdebug

There should be ONLY ONE zend_extension, either ZendDebugger.so or xdebug.so













Comments