Monday, 19 February 2007
Debugging PHP with Firebug |
| |
|
| |
With an introduction of a new Firefox extension in PHP, Terry Chay comments in his blog about the nitty-gritty that he had experienced working on it.
He first explains the purpose that this extension allows PHP scripts to send debugging or profiling information to Firefox’s Firebug without having to write the page itself. He says the standard way of debugging in PHP involves echoing code to the screen. The fact that PHP is a scripting language makes this an way of debugging on the Web. But this may lead to some breaks in your site. This is especially relevant when you are debugging a well formed XML or JSON response, he says.
He gives a solution to this and says that the trick is to use ‘detect the incoming HTTP request’ and then if Firebug is enabled, send a multipart/mixed MIME return. The first part contains the primary data and the second part contains a text/firephp file which consists of an XML of the information you have displayed. Bit initially he says to create HTML and it just renders it in the debugging window.
The problem he faces is when he wants to use it on the existing site without changing anything. But the way the PEAR library is written, it doesn’t play nice with output buffering or header calls, so he tried his own version which can be downloaded here. He informs that the version is PHP4 compatible
He says to install the version, just drop the files in your include_path and make sure you have the Firefox FirePHP extension installed. He then creates a web page with a code and he views with the Firebug on. A screenshot is provided for better understanding. He says to note that the only relevant part is the first two lines and the rest is given so you can understand how the features work. |
| |
|
Read the Post
|
| |
|
|
| |
|
|
| |
|