[wp-hackers] Debugging WordPress in IDE

Martin Widmann widmann.martin at gmail.com
Mon Mar 28 08:49:22 UTC 2011


It's actually pretty easy to set up. First of all you need to get the debugging running with Netbeans and Apache. This is done by installing the XDEBUG Plugin and enabling in in the php.ini. 

Here's how the part looks like in my php.ini, you'll most probably just need to change the path to the module:

[xdebug]
zend_extension="/Applications/MAMP/bin/php5.2/lib/php/extensions/no-debug-non-zts-20060613/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.idekey=
xdebug.profiler_enable=0
xdebug.profiler_output_dir=/tmp/
xdebug.profiler_enable_trigger=1

I also enabled the profiling methods in xdebug to be available when appending XDEBUG_PROFILE=1 to the Querystring. In that case I get a nice profiling cachegrind file in /tmp I can then analyze either in WinCacheGrind (http://sourceforge.net/projects/wincachegrind/) or WebGrind (http://sourceforge.net/projects/wincachegrind/). There's sadly no free Mac client. :(

In Netbeans I followed the instructions found in netbeans wiki http://netbeans.org/kb/docs/php/configure-php-environment-mac-os.html, but other then enabling "Watches and Balloon Evaluation" nothing needs to be done, IIRC.

You can then start debugging out of the IDE by setting breakpoints and using the "Debug Main Project" Button in the toolbar.

One more information about how I set up the projects in my IDE. When we decided to move to WordPress we wanted to have a good way to guarantee that nobody in the team changed anything in the wordpress core. Therefore we decided to relocate wp-content by setting WP_CONTENT_DIR to the project dir. Wordpress core is always in /var/www/wordpress-core and is updated via svn to the current trunk or tag depending on what I'm currently working on.

Netbeans makes it extremely easy to run this kind of setup! My nbproject files are in the project repository and the core is included in the project by setting /var/www/wordpress-core as a Global Include Path in the PHP settings in NetBeans' preferences.

Hope this helps!

--
Martin

On Mar 28, 2011, at 10:26 , Hannit Cohen wrote:

> Can any of you share how to setup NetBeans to debug WordPress ?
> -- 
> Hannit



More information about the wp-hackers mailing list