Advanced PHP debugger APD
&reftitle.intro; APD is the Advanced PHP Debugger. It was written to provide profiling and debugging capabilities for PHP code, as well as to provide the ability to print out a full stack backtrace. APD supports interactive debugging, but by default it writes data to trace files. It also offers event based logging so that varying levels of information (including function calls, arguments passed, timings, etc.) can be turned on or off for individual scripts. APD is a Zend Extension, modifying the way the internals of PHP handle function calls, and thus may or may not be compatible with other Zend Extensions (for example Zend Optimizer).
&reference.apd.configure; &reference.apd.ini;
&reftitle.resources; &no.resource;
&reftitle.constants; &no.constants;
How to use PHP-APD in your scripts As the first line of your PHP script, call the apd_set_pprof_trace() function to start the trace: You can insert the line anywhere in your script, but if you do not start tracing at the beginning of your script you discard profile data that might otherwise lead you to a performance bottleneck. Now run your script. The dump output will be written to apd.dumpdir/pprof_pid.ext. If you're running the CGI version of PHP, you will need to add the '-e' flag to enable extended information for apd to work properly. For example: php -e -f script.php To display formatted profile data, issue the pprofp command with the sort and display options of your choice. The formatted output will look something like: The -R option used in this example sorts the profile table by the amount of real time the script spent executing a given function. The "cumm call" column reveals how many times each function was called, and the "s/call" column reveals how many seconds each call to the function required, on average. To generate a calltree file that you can import into the KCacheGrind profile analysis application, issue the pprof2calltree comand.
Contact information If you have comments, bugfixes, enhancements or want to help developing this beast, you can send an mail to &email.apd;. Any help is very welcome.
&reference.apd.functions;