Tuesday, February 2, 2010

Debugging PHP with NetBeans & Xdebug & Ubuntu

It was almost impossible with my config to get working Zend Studio debugging, I think I achieved it once over the years, but it crashed my apache often, so wasnt that good solution neither. For development environment I use ubuntu/debian, vhosts with mod_rewrite, therefore need remote debugging.

Useful links info :

* Configure Xdebug in NetBeans
* Netbeans debugger in general


I had Xdebug set up and NetBeans fully supports it so gave it a try.

in Project Properties->Run Configuration, advanced button

- added Server path/Local path mappings for project ,
- debug Url set to "Ask every time", because I was about to debug remote mod_rewrite urls

For some odd reason, it wasnt working out of the box, Xdebug and NetBeans wasnt communicating well (it probably will work for you out of the box, my machine is cursed :), nothing "easier" that debug the debugger... needed some info

Edited /etc/netbeans.conf and changed php dbgp debug level:

netbeans_default_options="-J-client -J-Xverify:none -J-Xss2m -J-Xms32m -J-XX:PermSize=32m -J-XX:MaxPermSize=200m -J-Dapple.laf.useScreenMenuBar=true -J-Dsun.java2d.noddraw=true -J-Dorg.netbeans.modules.php.dbgp.level=400"

IDE debug log is accessible at (with output from dbgp): View->IDE log,

Xdebug logs location is at xdebug.remote_log defined in your php.ini

It turned out that it had something to do with my xdebug settings in php.ini. My final settings are:

zend_extension="/usr/lib/php5/20060613+lfs/xdebug.so"

xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9000
xdebug.remote_log=/var/log/xdebug.log
xdebug.extended_info=1

And it finally found my break point, on custom remote url, hurray :) Long live NetBeans & Xdebug

No comments: