Javascript developers use Firebug for debugging. I have always envied them. It’s cool to have a console, net monitoring and a debugger; all this stuff is in your favorite browser.
So, I have found such Firebug extension as FirePHP. It allows to output information into Firebug console directly from PHP. This is done by a simple execution:
require "FirePHP.class.php"; $firephp = FirePHP::getInstance(true); $firephp -> fb("hello world! i'm warning you!",FirePHP::WARN);
Also you may send arbitrary data structures and exceptions in Firebug. In the latter case we obtain not only exception object itself, but also stack contents. There are a lot of opportunities, you should read the documentation.
The advantage of such debugging is that data is not transferred to the body of a page, but in headers. This means that, firstly, the page does not foul up with all sorts of var_dump, and secondly, you can easily debug AJAX calls.
In order to use FirePHP you need to connect one file to the project and enable output buffering. That's all.
Speaking about buffering, FirePHP actually wants no one to write anything to the output stream before it. It is reasonable, because it sends the headers. If probably you have already been using buffering to send your own headers, then it is not a problem. I mean, it is not necessary to use ob_start(), as mentioned in the manual.
I do not advise to shove the calls fb() directly into your code. Think about what will happen to them on the production server. It is more correct to inject FirePHP to the debug system, for example, there are already extensions for Zend Framework and Symfony.