Install Xdebug and configure it with Netbeans

Installing Xdebug

1. Install Xdebug for php

sudo apt-get install php5-xdebug

2. Setup xdebug.ini for ubuntu

vim /etc/php5/fpm/conf.d/20-xdebug.ini

Add following lines:

xdebug.profiler_output_dir=/tmp
xdebug.profiler_output_name=cachegrind.out.%p
xdebug.profiler_enable_trigger=1
xdebug.profiler_enable=0
xdebug.remote_enable=true
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9001
xdebug.remote_handler=dbgp
xdebug.remote_autostart=0

3. Restart php5-fpm

sudo service php5-fpm restart

Configuring Netbeans:

xdebug-netbeans

  1. Go to Tools > Options > PHP > Debugging
  2. Set Debugging Port : 9001
  3. Start Debugging your project by Ctrl+F5 or file by Ctrl+Shift+F5

For WordPress Plugin/Theme:

WordPress-Xdebug-Netbeans-1

  1. Go to Project Properties > Run Configuration. Set Project URL.
  2. Go to Advanced Options.
SourceCode-xdebug-Netbeans-Mapping

  1. Map your local project path (source code directory) with the server path (plugin/theme directory on your server).
  2. Start Debugging your theme/plugin.

For more details, check out the Xdebug Documentation.