PHP debugging and profiling with xdebug
On Debian:
apt-get install php5-xdebug kcachegrind
Having the xdebug module around will already provide better debugging output in case of fatal errors and uncaught exceptions. The output can still be tweaked though:
In /etc/php5/conf.d/xdebug.ini, below the zend_extension line, add the following:
xdebug.var_display_max_children = 512
xdebug.var_display_max_data = 2048
xdebug.var_display_max_depth = 10
For profiling, add:
xdebug.profiler_enable = 1
xdebug.profiler_output_dir = /my/desired/outputdir
Create the directory configured on the xdebug.profiler_output_dir line and make it writable for the webserver user (www-data). Profiling data will be written to that dir (keep an eye on the amount of data produced though -- you may want to switch it off when you're not profiling!). kcachegrind is a great tool for vizualizing the data.
Docs: http://www.xdebug.org/docs/