When I originally wrote FirePHP in 2007 I had big ambitions as to the features I was going to incorporate. I learned quickly that the kinds of things I wanted to do were not going to be easy to implement in a maintainable way using existing code I had and open source code I could find. What I needed was a wholistic approach to the problem area of server-side application intelligence and a set of libraries based on standards that could be applied cross language.
After countless hours of research and development I am pleased to announce the first fruit of my labor.
FirePHP Companion is an alternative client for FirePHP that goes well beyond simple console logging and provides many features integral to an efficient development and debugging workflow.
I think this time around I am much closer to hitting the mark I was after to begin with and I hope you will judge my approach for yourself. FirePHP Companion is a commercial tool ($99 USD when released) with a free LITE version intended to replace the existing FirePHP Firefox Extension. Both editions use the same server library (FirePHP 1.0) and while the free version will focus on logging from server-side code to Firebug, the paid version will focus on providing a complete end-to-end development and debugging solution that seamlessly integrates with your existing applications.
- PHP 5.3+ (PHP 5.1+ if you use the zip archive)
- Firefox 3.6+
- Install Firebug: http://getfirebug.com/
- Install FirePHP Companion: http://www.christophdorn.com/Tools/
- Download FirePHP 1.0: http://reference.developercompanion.com/#/Tools/FirePHPCompanion/Install/
NOTE: The FirePHP 1.0 release will make it onto www.firephp.org later this year.
Let’s assume you are using the phar archive and you have the hostname http://demo.localhost/ mapped to a directory containing an index.php file and the phar archive.
define('INSIGHT_IPS', '*'); define('INSIGHT_AUTHKEYS', ''); define('INSIGHT_PATHS', __DIR__); define('INSIGHT_SERVER_PATH', '/index.php'); require_once('phar://'.__DIR__.'/firephp.phar/FirePHP/Init.php');
When you integrate FirePHP into your application the code above should be place at the top of your bootstrap file to enable FirePHP for your entire application.
Once included you can start logging to FirePHP Companion:
$inspector = FirePHP::to('request'); $console = $inspector->console('Debug'); $console->log('Hello World');
This works by first selecting the request context and obtaining a named console called Debug and then logging to it. In FirePHP Companion this will be displayed as follows:
To see the messages you have logged follow these steps:
- Using Firefox browse to http://demo.localhost/
- Open Firebug and enable the Net panel
- Refresh the page for the request to show up in the Net panel and expand it
- Select the Insight tab
- Set the INSIGHT_AUTHKEYS constant in index.php to the authorization key displayed
- Refresh the page, expand the request in the Net panel and select the Insight tab again
- Click Inspect with Companion which will load the Companion Window
Congratulations! You have logged your first message.
FirePHP Companion includes a comprehensive Reference that holds relevant documentation for all FirePHP features. To access the documentation launch the Companion Window (double-click in the Firefox status bar) and click on the Reference button in the footer. Once loaded click on the Tools section on the left.
You can also access the Reference here: http://reference.developercompanion.com/
I am hoping this is all the information you need to get started with FirePHP Companion. It’s a feature-packed tool that will only get better and I hope you will follow it’s progress. I will be posting a lot more information, tutorials and screencasts so subscribe to my blog or follow me on twitter.