It is possible with Eclipse and XDebug php extension... ( thanks to this article )

Stack trace,
breakpoints,
watch expressions,
variables,
...
The steps :
Install Xdebug :
sudo apt-get install php5-xdebug
Then, edit extension's php config :
sudo vi /etc/php5/conf.d/xdebug.ini
And add just after the line 'zend_extension=...' :
xdebug.remote_enable=On
xdebug.remote_host="localhost"
xdebug.remote_port=9000
xdebug.remote_handler="dbgp"
xdebug.max_nesting_level=1000
xdebug.collect_params=2
xdebug.collect_return=On
Then, restart your Apache :
sudo /etc/init.d/apache2 restart
It's time to configure your Eclipse :
You surely will have to configure the Browser to 'external web browser' in your Preferences->General->Web Browser configuration.
use 'Run' menu or 'Debug' toolbar icon to access 'Open Debug Dialog'.
Make a 'New' PHP Web Page configuration
- edit the first tab ( server ) :
- Choose XDebug as server debugger.
- Make a new PHP Server if you have a virtualHost ( in my example: http://symfony.me )
- Set 'File' Field to the absolute path of your front controller ( in my example: /var/www/symfony/web/frontend_dev.php )
- Uncheck 'Break at first line'
- Uncheck AutoGenerate URL to make it the same as when you debug your app ( in my example: http://symfony.me/frontend_dev.php/
- check Open in browser
- choose Start Debug from and add (in my example) : http://symfony.me/frontend_dev.php
- check 'Continue Debug from this page'
That's It !
Now start debugging :
Add a breakpoint by right clicking a line number in your file -> toggle breakpoint.
the PHP debug perspective contains an Expression View where you can add your own watch expressions.
Discover the tool as I'm actually doing :) !

4 commentaires:
Thank you very-very much for your blog post, I am finally able to debug my application, no need any more to log zillions of lines :)))
I really appreciate your work! Thanks!
With php 5.3 add the following lines to the end of your php.ini
[XDebug]
zend_extension="d:\xdebug.dll"
xdebug.remote_enable=true
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9000
xdebug.remote_handler=dbgp
xdebug.profiler_enable=0
xdebug.profiler_output_dir="d:\temp"
absolute perfect, thanks a lot!
phil
Thanks for the feedback !
Enregistrer un commentaire