Mar 302011
 

1. Installation
Create a file “package.json” with the following content (set uid of your package)
{
"uid": "(your package uid)"
}

Create a file called “package.json” with with content as example below (add IP restriction or/and keys), the example gives unlimited access.
{
"cadorn.org/insight/@meta/config/0": {
"allow": {
"ips": [ "*" ],
"authkeys": [ "*" ]
}
}
}

Download the server library, the easiest is to use phar file, and set up your virtual host:
<VirtualHost *:80>
php_value auto_prepend_file phar:///var/www/firePHP_1.0/firephp.phar/FirePHP/Init.php
SetEnv INSIGHT_CONFIG_PATH /var/www/firePHP_1.0/package.json,/var/www/firePHP_1.0/credentials.json
...
</VirtualHost>

Install client plugin (FirePHP Companion) in your web browser,

2. Page Context
$inspector = FirePHP::to("page");
$console = $inspector->console();
$console->log("Hello World");

3. Request Context
$inspector = FirePHP::to("request");
$console = $inspector->console();
$console->log("Hello World");

4. Controller Context
$inspector = FirePHP::to("request");
$console = $inspector->console();
$console->log("Hello World");
$controller = FirePHP::to("controller");
$controller->triggerInspect()


5. Package Context

$package = FirePHP::to("package");
$package->addQuickLink("Link 1", "http://www.firephp.org/");
$package->addQuickLink("Link 2", array(
"target" => "window", // tab (default), window or hidden
"url" => "http://www.firephp.org/"
));


$controller = FirePHP::to("controller");
$controller->triggerInspect();

6. Basic API
$inspector = FirePHP::to("request");
$console = $inspector->console();
$variable = "Hello World";

$console->log($variable);
$console->info($variable);
$console->warn($variable);
$console->error($variable);

// Message Label
$console->label("My label")->log($variable);

// Table
$header = array("Column 1 Heading", "Column 2 Heading");
$table = array(
array("Row 1 Column 1 Value", "Row 1 Column 2 Value"),
array("Row 2 Column 1 Value", "Row 2 Column 2 Value"),
);
$console->table("Table", $table);
$console->table("Table with header", $table, $header);

// Stack Traces
$console->trace("My stack trace");

// Group
$group = $console->group("myGroup", "Group Title")->open();
$console->info("Hey!, I am in a group");
$console->error("I am in a group too!");
$group->close();


// Console controller
$controller = FirePHP::to("controller");
$controller->triggerInspect();

7. Conditional Logging

$inspector = FirePHP::to("request");
$console = $inspector->console();

$console->on("Show warnings")->warn("I am warning you!");

// Console controller
$controller = FirePHP::to("controller");
$controller->triggerInspect();

8. Engine API
$inspector = FirePHP::to("request");
$console = $inspector->console();
$engine = FirePHP::plugin("engine");
// Send all exceptions and errors to a specific console
$engine->onError($console);
$engine->onAssertionError($console);
$engine->onException($console);
// Console controller
$controller = FirePHP::to("controller");
$controller->triggerInspect();

// Handle manually
try {
throw new Exception("Hello, I am a manually handled exception");
} catch(Exception $e) {
$engine->handleException($e);
}

throw new Exception("Test Exception");

9. FirePHP API
$inspector = FirePHP::to("request");

// Log p() messages to the provided console
$firephp = FirePHP::plugin("firephp");
$inspectorConsole = $inspector->console("InspectorConsole");
$firephp->declareP($inspectorConsole, true);

$variable = array("key"=>"value");
p($variable); // or
p($inspector, "Inspector");

// Log the current FirePHP version to a FirePHP console.
$versionConsole = $inspector->console("Version Console");
$firephp->logVersion($versionConsole);

// Send information about the PHP environment to an Environment console.
$envConsole = $inspector->console("Environment");
$firephp->recordEnvironment($envConsole);

// Console controller
$controller = FirePHP::to("controller");
$controller->triggerInspect();

//Send all errors and exceptions to a Problems console.
$problemConsole = $inspector->console("Problem Console");
$firephp->trapProblems($problemConsole);

throw new Exception("I am your problem");

 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>