Tags

, ,


In complex and large scale php application we need to debug the php code to easier life. Xdebug is a PHP extension which help us to debug applications.

This tutorial will shows how to configure Xdebug extension with NetBeans IDE in Ubuntu Linux.

I assume that in your ubuntu system, you have already installed php and configured LAMPP [ LINUX,Apache,MySQL,PHP]. so i start direct from configure the xdebug
This tutorial is tested on following configuration.

Apache 2.0
PHP Version 5.3.8
Netbeans 7.2.1
Ubuntu 12.04

step 1:
To install xdebug in ubuntu ,open terminal window and write following command. this command will install xdebug extension in ubuntu os.

sudo apt-get install php5-xdebug

step 2:
Edit php.ini write following command in terminal. so you can add xdebug configuration code.

sudo gedit /opt/lampp/etc/php.ini

and add following code at the bottom of the php.ini file

zend_extension = /usr/lib/php5/20090626+lfs/xdebug.so
xdebug.remote_enable=on
xdebug.remote_log=”/var/log/xdebug.log”
xdebug.remote_host=localhost
xdebug.remote_handler=dbgp
xdebug.remote_port=9000

step 3: you need to restart the apache server write following command. Click here if you want to see more commands Operate XAMPP
sudo /opt/lampp/lampp restart

step 4:
Now open brower and see localhost url (http://localhost/xampp/) and click on phpinfo() link to check that xdebug extension is configured successfully. if xdebug is install then it will looks like the following image.please see following image

phpinfo-xdebug

phpinfo-xdebug

step 5:

Finally open Netbeans IDE to add xdebug configuration .

Open Tools >> Options
click on “php” tab then click on “Debugging”

and write following configuration here.
Debugger Port : 9000
Session ID : netbeans-xdebug

see following images for above settings

netbeans-xdebug-window

netbeans-xdebug-window

Then click on ok button to save changes.
step 6: Thats it!! Now you can debug the php code in netbeans.
Enjoy Coding !!

Advertisements