debug php using firebug and firephp

3
Debug PHP Using Firebug and FirePHP Firebug is a phenomenally helpful HTML / CSS / JavaScript / Ajax debugger. Be that as it may, did you know it can likewise be utilized to troubleshoot PHP? Yes, on account of an additional Firefox extension called FirePHP. By consolidating this expansion, which sits on top of Firebug, with a server-side library, your PHP scripts will have the capacity to send troubleshooting data to the program, helpfully encoded in the HTTP reaction headers. Once you're set up, you can log notices and slips in your PHP scripts to the Firebug reassure, pretty much as though you were creating JavaScript. To begin, you initially need to introduce the FirePHP extension from Mozilla's Firefox Add-ons site. This obliges that you as of now have Firebug introduced. When FirePHP is introduced, when you next open your Firebug board, you'll now see an extra blue bug. Click on that bug and a menu will seem permitting you to empower or incapacitate FirePHP:

Upload: shahriar-kabir

Post on 23-Jul-2016

256 views

Category:

Documents


5 download

DESCRIPTION

Firebug is a phenomenally helpful HTML / CSS / JavaScript / Ajax debugger. Be that as it may, did you know it can likewise be utilized to troubleshoot PHP? Yes, on account of an additional Firefox extension called FirePHP. By consolidating this expansion, which sits on top of Firebug, with a server-side library, your PHP scripts will have the capacity to send troubleshooting data to the program, helpfully encoded in the HTTP reaction headers. Once you're set up, you can log notices and slips in your PHP scripts to the Firebug reassure, pretty much as though you were creating JavaScript.

TRANSCRIPT

Debug PHP Using Firebug and FirePHP

Firebug is a phenomenally helpful HTML / CSS / JavaScript / Ajax debugger. Be that as it may,

did you know it can likewise be utilized to troubleshoot PHP? Yes, on account of an additional

Firefox extension called FirePHP. By consolidating this expansion, which sits on top of Firebug,

with a server-side library, your PHP scripts will have the capacity to send troubleshooting data to

the program, helpfully encoded in the HTTP reaction headers. Once you're set up, you can log

notices and slips in your PHP scripts to the Firebug reassure, pretty much as though you were

creating JavaScript.

To begin, you initially need to introduce the FirePHP extension from Mozilla's Firefox Add-ons

site. This obliges that you as of now have Firebug introduced. When FirePHP is introduced,

when you next open your Firebug board, you'll now see an extra blue bug. Click on that bug and

a menu will seem permitting you to empower or incapacitate FirePHP:

This, obviously, won't do anything yet. You likewise need to introduce the FirePHP

server-side library, which is accessible here. This is a stand-alone form of the library

that can either be downloaded physically or introduced utilizing PEAR. After that, you

basically need to incorporate the library in your code. There are likewise forms

intended to coordinate with different structures or substance administration

frameworks, for example, the WP-FirePHP plugin for WordPress or the JFirePHP

plugin for Joomla. For the purpose of this stroll through, I'll concentrate on the stand-

alone usefulness.

When you have the FirePHP library on your server, you have to incorporate it in your

script with a line like:

require_once('FirePHPCore/fb.php');

Since FirePHP sends its logging information by means of the HTTP headers, you'll

have to cradle your script's yield so that the reaction headers can incorporate

substance produced further down the script. In PHP, this is expert by

calling ob_start close to the highest point of your script:

ob_start();

With these steps done, you can begin utilizing FirePHP. You should do nothing more

than call the fb function with whatever you'd like to log, alongside a discretionary

name and a discretionary steady to characterize the message as a standard log, a

notice, a mistake, or data. For example:

$var = array('a'=>'pizza', 'b'=>'cookies', 'c'=>'celery'); fb($var); fb($var, "An array"); fb($var, FirePHP::WARN); fb($var, FirePHP::INFO); fb($var, 'An array with an Error type', FirePHP::ERROR);

This code will produce the following output in the Firebug console:

You can likewise utilize FirePHP to give you a hint of your application's execution: by going in

the FirePHP::TRACE consistent, you'll get the opportunity to see the line number, class name,

and capacity name from inside which fb was called. So this code:

function hello() { fb('Hello World!', FirePHP::TRACE); } function greet() { hello(); } greet();

Will produce an output as follows:

This follow usefulness can be fabulous for troubleshooting more included scripts, as it tells you

precisely from where your capacities are being called

Obviously, you have to recall to uproot you're troubleshooting explanations before your code goes live! There's a ton more to FirePHP than what I've covered here. I've been demonstrating to you the disentangled procedural API for FirePHP, however there's a more propelled article situated API accessible with various extra elements. You can realize about it on the FirePHP site, so make sure to look at it.

Shahriar Kabir