Saturday, March 17, 2012

configure xdebug netbeans ubuntu linux



Developers frequently need to trace the execution of their code, and debug it, and Drupal/PHP is no exception.
There are several PHP debugging frameworks/APIs available, including DBG, Gubed, Zend, and xdebug. Each of those supports different IDEs (Integrated Development Environments).
This article focuses on xdebug, and how you can set it up on your development machine or server.
xdebug provides the ability for more than one person to have debug sessions concurrently on the same server, using the DBGp protocol. Not all IDE's available support this feature however.
IDEs that use DBGp at present are:
  • Vim with the xdebug plugin (command line, non-GUI).
  • ActiveState Komodo (multi-platform)
  • Quanta Plus (KDE on Linux)

Installation

To install xdebug on a debian/Ubuntu system enter the following commands from sudo bash or root shell:
First, install PHP and MySQL if you already do not have them. You may not need the gd library if you do not have image manipulation modules.
aptitude install apache2 php5 php5-gd mysql-server php5-mysql
Next, install PHP development, Apache development, and PEAR.
aptitude install apache2-dev php5-dev php-pear make
Lastly, install xdebug using PHP's pecl
pecl install xdebug-beta 
This last step will run for a while, compiling xdebug from source. It should not have any errors.

Configuration

After the last command completes, you will have an xdebug.so library. You now need to configure apache to use it.
To do this, edit your PHP configuration file /etc/php5/apache2/php.ini and add in it the following section just before the [Date] heading:
zend_extension=/usr/lib/php5/20051025/xdebug.so

[debug]
; Remote settings
xdebug.remote_autostart=off
xdebug.remote_enable=on
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_host=localhost
xdebug.remote_port=9000

; General
xdebug.auto_trace=off
xdebug.collect_includes=on
xdebug.collect_params=off
xdebug.collect_return=off
xdebug.default_enable=on
xdebug.extended_info=1
xdebug.manual_url=http://www.php.net
xdebug.show_local_vars=0
xdebug.show_mem_delta=0
xdebug.max_nesting_level=100
;xdebug.idekey=

; Trace options
xdebug.trace_format=0
xdebug.trace_output_dir=/tmp
xdebug.trace_options=0
xdebug.trace_output_name=crc32

; Profiling
xdebug.profiler_append=0
xdebug.profiler_enable=0
xdebug.profiler_enable_trigger=0
xdebug.profiler_output_dir=/tmp
xdebug.profiler_output_name=crc32
If you are using this on a server that is separate from the machine that you run the IDE in, then change the host name in xdebug.remote_host from localhost to the name of your server.

http://netbeans.org/kb/docs/php/configure-php-environment-ubuntu.html