PHP Xdebug


Example

Xdebug is a PHP extension which provides debugging and profiling capabilities.
It uses the DBGp debugging protocol.

There are some nice features in this tool:

  • stack traces on errors
  • maximum nesting level protection and time tracking
  • helpful replacement of standard var_dump() function for displaying variables
  • allows to log all function calls, including parameters and return values to a file in different formats
  • code coverage analysis
  • profiling information
  • remote debugging (provides interface for debugger clients that interact with running PHP scripts)

As you can see this extension is perfectly suited for development environment. Especially remote debugging feature can help you to debug your php code without numerous var_dump's and use normal debugging process as in C++ or Java languages.

Usually installing of this extension is very simple:

pecl install xdebug # install from pecl/pear

And activate it into your php.ini:

zend_extension="/usr/local/php/modules/xdebug.so"

In more complicated cases see this instructions

When you use this tool you should remember that:
XDebug is not suitable for production environments