Mar 302011
 

1. FirePHP 0.5 – Installation
1. Dwonload The Server Library and include it
2. require_once("./FirePHPCore-0.3.2/lib/FirePHPCore/FirePHP.class.php");
Or find a plugin for your framework.

2. Object Oriented API
require_once("./FirePHPCore-0.3.2/lib/FirePHPCore/FirePHP.class.php");
$firephp = FirePHP::getInstance(true);
$firephp->log("Hello World");

3. Procedural API
require_once("./FirePHPCore-0.3.2/lib/FirePHPCore/fb.php");
fb("Hello World");
fb("Hello World", "Label");

4. Options
require_once("./FirePHPCore-0.3.2/lib/FirePHPCore/FirePHP.class.php");

// Defaults:
$options = array("maxObjectDepth" => 5, // Maximum depth to traverse objects.
"maxArrayDepth" => 5, // Maximum depth to traverse arrays.
"maxDepth" => 10, // Maximum depth to traverse mixed arrays/objects.
"useNativeJsonEncode" => true, // Set to FALSE to use JSON encoder included with FirePHPCore instead of json_encode().
"includeLineNumbers" => false); // Include File and Line information in message

$firephp = FirePHP::getInstance(true);
$firephp->setOptions($options);
$firephp->log("Hello World");

5. Log level
require_once("./FirePHPCore-0.3.2/lib/FirePHPCore/FirePHP.class.php");

$firephp = FirePHP::getInstance(true);
$firephp->log("Logs a message to firebug console.");
$firephp->info("Logs a message to firebug console and displays an info icon before the message.");
$firephp->warn("Logs a message to firebug console, displays an warning icon before the message and colors the line turquoise.");
$firephp->error("Logs a message to firebug console, displays an error icon before the message and colors the line yellow. Also increments the firebug error count.");
// or
$firephp->fb("Log with fb() method", FirePHP::LOG);
$firephp->fb("Info with fb() method", FirePHP::INFO);
$firephp->fb("Warning with fb() method", FirePHP::WARN);
$firephp->fb("Error with fb() method", FirePHP::ERROR);

6. Dump
require_once("./FirePHPCore-0.3.2/lib/FirePHPCore/FirePHP.class.php");

$firephp = FirePHP::getInstance(true);
$firephp->dump("array",array("key"=>"value"));
$firephp->dump("firePHP",$firephp);

7. Trace
require_once("./FirePHPCore-0.3.2/lib/FirePHPCore/FirePHP.class.php");

$firephp = FirePHP::getInstance(true);
$firephp->trace("Trace Label");

8. Groups
require_once("./FirePHPCore-0.3.2/lib/FirePHPCore/FirePHP.class.php");

$firephp = FirePHP::getInstance(true);
$firephp->group("Test Group");
$firephp->log("Hello World");
$firephp->groupEnd();

$firephp->group("Collapsed and Colored Group",
array("Collapsed" => true,
"Color" => "#FF00FF"));
$firephp->log("Hello World");
$firephp->groupEnd();

9. Tables
require_once("./FirePHPCore-0.3.2/lib/FirePHPCore/FirePHP.class.php");

$firephp = FirePHP::getInstance(true);

$table = array();
$table[] = array("Col 1 Heading","Col 2 Heading");
$table[] = array("Row 1 Col 1","Row 1 Col 2");
$table[] = array("Row 2 Col 1","Row 2 Col 2");
$table[] = array("Row 3 Col 1","Row 3 Col 2");

$firephp->table("Table Label", $table);

10. Exception Handling
require_once("./FirePHPCore-0.3.2/lib/FirePHPCore/FirePHP.class.php");

$firephp = FirePHP::getInstance(true);
$firephp->registerErrorHandler( $throwErrorExceptions=false);
$firephp->registerExceptionHandler();
$firephp->registerAssertionHandler( $convertAssertionErrorsToExceptions=true, $throwAssertionExceptions=false);

throw new Exception("Test Exception");
// or manually
try {
throw new Exception("Test Exception");
} catch(Exception $e) {
$firephp->error($e);
}

11. Disabling firePHP
require_once("./FirePHPCore-0.3.2/lib/FirePHPCore/FirePHP.class.php");

$firephp = FirePHP::getInstance(true);
$firephp->log("Hello");
$firephp->setEnabled(false);
$firephp->log("Hello again");

 Leave a Reply

(required)

(required)

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>