The most common issue when we are developing web application using PHP is debugger. Debugging our web application is very important when we are developing and testing our project. Usually i’m using var_dump(), print_r() or echo to show the output of the variable or the result. The alternative is using Zend Studio, the PHP IDE (Integrated Development Environment), but it is too expensive and i couldn’t afford it now.
So the alternatively to see how your web application works is using XDebug. XDebug is a PHP extension for debugging and profiling. It supports stack and function traces, profiling information and memory allocation and script execution analysis. And it is free to use.
XAMPP for Windows already include xdebug in it, but not yet enabled.
To enable it just open the php.ini and enable:
zend_extension = "pathtophpextphp_xdebug.dll"
To install xdebug on Linux, you can use pecl:
pecl install xdebug
How to use XDebug:
- Auto trace mode:
Xdebug have auto trace mode, you can enable it in php.ini:
in this mode, xdebug will write the log into c:data for every php code runned.
- Manually add xdebug for tracing part of code:
When you come down to trace part of your code you can manually add xdebug code in your code, so you can have the trace result:
xdebug_start_trace('c:/data/fac.xt'); //Bunch php code here xdebug_stop_trace();
With Xdebug we can find where our code go wrong and fix it. It is pretty handy tools to increase your productivity and less bugs web application.
Introducing Xdebug – Zend article
Give me your feedback