<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Christoph Dorn - All around the PHP toolchain</title>
	<atom:link href="http://www.christophdorn.com/Blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.christophdorn.com/Blog</link>
	<description>Just another WordPress site</description>
	<lastBuildDate>Wed, 03 Aug 2011 21:56:53 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>FirePHP and Firebug 1.8</title>
		<link>http://www.christophdorn.com/Blog/2011/08/03/firephp-and-firebug-1-8/</link>
		<comments>http://www.christophdorn.com/Blog/2011/08/03/firephp-and-firebug-1-8/#comments</comments>
		<pubDate>Wed, 03 Aug 2011 21:56:52 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Developer Companion]]></category>
		<category><![CDATA[FirePHP]]></category>
		<category><![CDATA[Firebug]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Zend Framework]]></category>

		<guid isPermaLink="false">http://www.christophdorn.com/Blog/?p=556</guid>
		<description><![CDATA[If you recently upgraded to Firebug 1.8 you will have noticed that FirePHP no longer worked and when visiting http://www.firephp.org/ you would have seen a notice prompting you to upgrade to DeveloperCompanion. The FirePHP Extension now (0.6) works again with &#8230; <a href="http://www.christophdorn.com/Blog/2011/08/03/firephp-and-firebug-1-8/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>If you recently upgraded to Firebug 1.8 you will have noticed that FirePHP no longer worked and when visiting <a href="http://www.firephp.org/">http://www.firephp.org/</a> you would have seen a notice prompting you to upgrade to <a href="http://docs.sourcemint.org/firephp.org/firephp/1/-docs/Clients#devcomp">DeveloperCompanion</a>.</p>
<p><strong>The FirePHP Extension now (0.6) works again with Firebug 1.8: <a href="http://www.firephp.org/HQ/FinalRelease.htm">http://www.firephp.org/HQ/FinalRelease.htm</a></strong> (will appear on <a href="https://addons.mozilla.org/en-US/firefox/addon/firephp/">mozilla add-ons</a> once approved)</p>
<h2>What Happened?</h2>
<p>I have been working on <a href="http://docs.sourcemint.org/firephp.org/firephp/1">FirePHP 1.0</a> (<a href="http://docs.sourcemint.org/firephp.org/firephp/1/-docs/Install">comparison</a>) for a few years now to come up with a streamlined way to develop PHP (and other languages) code in the modern web environment. To make this a reality a new server library and client is needed. I wrote both of these from scratch based on a bunch of <a href="http://www.christophdorn.com/Research/">research</a> utilizing the latest technologies (especially for the client).</p>
<p>What sets the FirePHP 1.0 (server library) apart is that it includes a new cross language intelligence system called <a href="http://docs.sourcemint.org/firephp.org/firephp/1/-docs/Insight">Insight</a> intended to bring the FirePHP way of debugging to other programming languages. Furthermore Insight is designed to support multiple clients that can embed the Insight system (composed of <a href="http://www.commonjs.org/">CommonJS</a> modules) in order to bring native support to IDEs and other developer tools (this aspect is not ready yet but will receive significant attention in time).</p>
<p>I wrote the new client (<a href="http://docs.sourcemint.org/firephp.org/firephp/1/-docs/Clients#devcomp">DeveloperCompanion</a>) to support all existing FirePHP Extension features plus new ones (to be released with Firebug 1.9) free of charge. The paid version builds on the free foundation by offering more streamlined and time-saving features.</p>
<p>The arrival of Firebug 1.8 brings along a <a href="http://getfirebug.com/wiki/index.php/Firebug_1.8_API_Changes">bunch of internal changes</a> which broke the FirePHP Extension 0.5 release. Given that DeveloperCompanion is sufficiently ready I decided not not fix the FirePHP Extension and thought I would upgrade users to DeveloperCompanion to ensure everyone can keep using  FirePHP with Firebug 1.8.</p>
<h2>Feedback from users</h2>
<p>Then I started receiving feedback about this decision. Users were not happy that they were now required to install a <em>commercial</em> extension. I did not think that this would be a problem. In my view the free features DeveloperCompanion offers are superior to the ones offered by the FirePHP Extension (if you don&#8217;t think they are let me know so we can make it so) and since 2007 I have received only one patch for the FirePHP Extension. I thought users would not object to a closed-source extension for a while until <a href="http://docs.sourcemint.org/firephp.org/firephp/1/-docs/Clients#fireconsole">FireConsole</a> is ready.</p>
<p>There seem to be two groups of FirePHP users. One is looking for and needs the new features that FirePHP 1.0 brings and the other is happy with the simple approach of the <a href="http://docs.sourcemint.org/firephp.org/firephp/1/-docs/Configuration/Traditional">FirePHPCore</a> library and insist on the entire stack being open source at all times.</p>
<h2>Go forward</h2>
<p><strong>I have decided to continue to maintain the FirePHP Extension</strong> but it will not be upgraded to be compatible with the new FirePHP 1.0 Insight features. That means the FirePHP Extension will continue to support the FirePHPCore library only and implementations written to be protocol compatible such as the native Zend Framework implementation.</p>
<p>Users who want to use the <a href="http://docs.sourcemint.org/firephp.org/firephp/1/-docs/Install">FirePHP 1.0 Insight</a> features with an open source extension will need to wait for <a href="http://docs.sourcemint.org/firephp.org/firephp/1/-docs/Clients#fireconsole">FireConsole</a>. Anyone who does not object to installing a free closed-source client can use the new FirePHP 1.0 Insight features today with <a href="http://docs.sourcemint.org/firephp.org/firephp/1/-docs/Clients#devcomp">DeveloperCompanion</a>.</p>
<p>Finally, anyone looking for features that will streamline their PHP and JavaScript development workflow and toolchain can license DeveloperCompanion and as a result support the further development of FirePHP, Insight and related technologies. I know we all love open source but producing open source software still takes time and money. I appreciate your support.</p>
<p>I trust that this will satisfy everyone&#8217;s needs. If not, please let me know.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.christophdorn.com/Blog/2011/08/03/firephp-and-firebug-1-8/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Zend Server + FirePHP on AWS</title>
		<link>http://www.christophdorn.com/Blog/2011/01/06/zend-server-firephp-on-aws/</link>
		<comments>http://www.christophdorn.com/Blog/2011/01/06/zend-server-firephp-on-aws/#comments</comments>
		<pubDate>Thu, 06 Jan 2011 00:34:59 +0000</pubDate>
		<dc:creator>Christoph Dorn</dc:creator>
				<category><![CDATA[FirePHP]]></category>
		<category><![CDATA[FirePHP Companion]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[aws]]></category>
		<category><![CDATA[Zend Server]]></category>

		<guid isPermaLink="false">http://www.christophdorn.com/Blog/?p=532</guid>
		<description><![CDATA[FirePHP can nicely complement the built-in tools available when using Zend Server and can be easily made available to all provisioned sites. This tutorial illustrates how to setup FirePHP 1.0 for all virtual hosts on a Zend Server AMI on &#8230; <a href="http://www.christophdorn.com/Blog/2011/01/06/zend-server-firephp-on-aws/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.firephp.org/">FirePHP</a> can nicely complement the built-in tools available when using <a href="http://www.zend.com/en/products/server/">Zend Server</a> and can be easily made available to all provisioned sites. This tutorial illustrates how to setup <a href="http://www.christophdorn.com/OpenSource/#FirePHP">FirePHP 1.0</a> for all virtual hosts on a <a href="http://www.zend.com/en/products/server/amazon/">Zend Server AMI</a> on <a href="http://aws.amazon.com/ec2/">Amazon EC2</a>.</p>
<h2>Launching Zend Server Instance on EC2</h2>
<p>Go to <a href="http://www.zend.com/en/products/server/amazon/">http://www.zend.com/en/products/server/amazon/</a> and follow the steps to launch an instance.</p>
<p><strong>NOTE:</strong> The Zend Server instances launched this way are billed to you on an hourly basis at a rate set by Zend.</p>
<p>The instructions below should work for any Zend Server or <a href="http://www.zend.com/en/community/zend-server-ce">Free Zend Server Community Edition</a> installation. The assumption is you are working with a <strong>new</strong> PHP 5.2+ Zend Server install. If you already have sites provisioned you can adapt the instructions to fit your needs.</p>
<p><span id="more-532"></span></p>
<p><script type="text/javascript" src="http://upgrade.firephp.org/widgets/install.php"></script></p>
<style>
#install-devcomp,
#install-firephp {
  padding-left: 20px;
}
#install-devcomp > A,
#install-firephp > A {
  border-bottom: 0px;
}
</style>
<h2>Install &amp; Download</h2>
<h3>Requirements</h3>
<ul>
<li><a target="_blank" href="http://getfirefox.com/">Firefox 3.6</a></li>
<li><a target="_blank" href="http://getfirebug.com/">Firebug 1.5+</a></li>
</ul>
<p>Install the <a href="http://www.christophdorn.com/Tools/#FirePHP Companion">FirePHP Companion</a> client extension:</h2>
<div id="install-devcomp"></div>
<p><script>
jQuery(function() {
  firephpInstallWidget({
    "element": "install-devcomp",
    "program": "cadorn.com/packages/devcomp/programs/firefox-extension"
  });
});
</script></p>
<p>Download the <a target="_blank" href="http://reference.developercompanion.com/#/Tools/FirePHPCompanion/Introduction/">FirePHP 1.0</a> server library</h2>
<div id="install-firephp"></div>
<p><script>
jQuery(function() {
  firephpInstallWidget({
    "element": "install-firephp",
    "program": "cadorn.org/github/firephp-libs/programs/standalone",
    "format": "phar"
  });
});
</script></p>
<h2>Upload</h2>
<p>SSH into the server and upload the <em>phar archive</em> you just downloaded to <em>/usr/local/zend/share/firephp/firephp.phar</em> (you will need to create the <em>firephp</em> folder).</p>
<h2>Configure</h2>
<p>We are going to <a href="http://reference.developercompanion.com/#/Tools/FirePHPCompanion/Install/">configure</a> <em>FirePHP</em> on a virtual host basis. Since we are working with a new server install that already has a default virtual host configured we are simply going to enable FirePHP for it.</p>
<p>Place the following just before the closing <em>VirtualHost</em> tag in the <em>/etc/apache2/sites-available/default</em> file:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">SetEnv INSIGHT_CONFIG_PATH /var/www/package.json,/usr/local/zend/etc/firephp/credentials.json
php_value auto_prepend_file phar:///usr/local/zend/share/firephp/firephp.phar/FirePHP/Init.php</pre></div></div>

<p>Restart <em>Apache</em> using the <em>Zend Server Administration Interface</em> by clicking on <em>Restart PHP</em> in the footer.</p>
<p><strong>NOTE:</strong> You can use the same <em>credentials.json</em> file for all virtual hosts or refer to specific credentials files as needed.</p>
<p>Create a credentials file for <em>FirePHP</em> at <em>/usr/local/zend/etc/firephp/credentials.json</em> (you will need to create the <em>firephp</em> folder) with the following content:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #009900;">&#123;</span>
  <span style="color: #3366CC;">&quot;cadorn.org/insight/@meta/config/0&quot;</span><span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #3366CC;">&quot;allow&quot;</span><span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #3366CC;">&quot;ips&quot;</span><span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span>
        <span style="color: #3366CC;">&quot;your-ip&quot;</span>
      <span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
      <span style="color: #3366CC;">&quot;authkeys&quot;</span><span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span>
        <span style="color: #3366CC;">&quot;your-authkey&quot;</span>
      <span style="color: #009900;">&#93;</span>
    <span style="color: #009900;">&#125;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p><strong>NOTE:</strong> Make sure to update the <em>your-ip</em> value to your IP which you can get by visiting <a href="http://myip.cadorn.net/">myip.cadorn.net</a>. Keep the <em>your-authkey</em> value until you get your own below.</p>
<p>Finally we need to configure the site/application provisioned at <em>/var/www</em>. <strong>The changes we make here should be made in the application source code (that will be deployed to the virtual host) and reside in source version control together with the rest of the application.</strong> This will ensure <em>FirePHP</em> will automatically start working for the application if provisioned on any server with <em>FirePHP</em> pre-configured.</p>
<p>Create a file at <em>/var/www/package.json</em> with the following content:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #009900;">&#123;</span>
  <span style="color: #3366CC;">&quot;uid&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;firephp-test.zendserver.aws.firephp.org&quot;</span><span style="color: #339933;">,</span>
  <span style="color: #3366CC;">&quot;implements&quot;</span><span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #3366CC;">&quot;cadorn.org/insight/@meta/config/0&quot;</span><span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #3366CC;">&quot;cache&quot;</span><span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #3366CC;">&quot;path&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;/usr/local/zend/tmp&quot;</span>
      <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
      <span style="color: #3366CC;">&quot;server&quot;</span><span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #3366CC;">&quot;path&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;/index.php&quot;</span>
      <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
      <span style="color: #3366CC;">&quot;paths&quot;</span><span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #3366CC;">&quot;./&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;allow&quot;</span>
      <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p><strong>NOTE:</strong> Make sure to update the <em>uid</em> property to a URI unique to your application. <strong>See <a href="http://reference.developercompanion.com/#/Tools/FirePHPCompanion/Install/#Configuration: package.json">here</a> for more information on the <em>uid</em> property and other configuration options.</strong></p>
<p>The default virtual host does not include a PHP file we can use for testing so we create one at <em>/var/www/index.php</em> with the following content:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'Hello World from Zend Server + FirePHP'</span><span style="color: #339933;">;</span></pre></div></div>

<p>We are now ready to authorize the client and log some test messages.</p>
<h2>Authorize Client</h2>
<p>In <em>Firefox</em>, open <em>Firebug</em>, enable the <em>Console</em>, <em>Net</em> and <em>Insight</em> panels and select the <em>Console</em> panel.</p>
<p>Load the <em>index.php</em> page (e.g. <em>http://ec2-xxx.compute-1.amazonaws.com/index.php</em>) and look for the <em>Authorization Key</em> logged to the <em>Firebug Console</em>.</p>
<p>Update the <em>your-authkey</em> value in the <em>credentials.json</em> file above to the <em>Authorization Key</em> copied from the <em>Firebug Console</em>. To keep track of which key belongs to whom you can set it as follows (notice the comment after the key):</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #009900;">&#123;</span> <span style="color: #3366CC;">&quot;cadorn.org/insight/@meta/config/0&quot;</span><span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span> <span style="color: #3366CC;">&quot;allow&quot;</span><span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #3366CC;">&quot;authkeys&quot;</span><span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span>
        <span style="color: #3366CC;">&quot;5312C15AF9D9C7610C8E33C854XXXXXX // user@ec2-xxx.compute-1.amazonaws.com&quot;</span>
      <span style="color: #009900;">&#93;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#125;</span></pre></div></div>

<p><strong>NOTE:</strong> Each client will have a unique key for each hostname provisioned to access the application. This has nothing to do with the <em>uid</em> property in <em>package.json</em> which is used to identify the application itself irrespective of where it is deployed.</p>
<h2>Test Debug Output</h2>
<p>You can now place logging calls using the <a href="http://reference.developercompanion.com/#/Tools/FirePHPCompanion/API/">Insight API</a> anywhere in the application and refresh your browser to see the result.</p>
<p>We are going to log a test message and information about the environment. Add the following to <em>/var/www/index.php</em>:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'Hello World from Zend Server + FirePHP'</span><span style="color: #339933;">;</span>
&nbsp;
FirePHP<span style="color: #339933;">::</span><span style="color: #004000;">to</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'page'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">console</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">log</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Hello World from FirePHP on Zend Server'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
FirePHP<span style="color: #339933;">::</span><span style="color: #004000;">plugin</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'firephp'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">recordEnvironment</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>This tells <em>FirePHP</em> to log <em>Hello World from FirePHP on Zend Server</em> to the <em>Firebug Console</em> followed by information about the environment. For a complete API reference see <a href="http://reference.developercompanion.com/#/Tools/FirePHPCompanion/API/">here</a>.</p>
<h2>Troubleshooting</h2>
<p>If you follow the instructions above you should not have any problems in getting <em>FirePHP</em> working on any <em>Zend Server</em> install.</p>
<p>The most common cause of problems are mistakes in the json configuration files. Any errors are logged to the PHP error log which you can access via the <em>Zend Server Administration Interface</em>.</p>
<p>If the error log does not help, the best place to start troubleshooting is by using the <em>Test Tool</em>. To launch go to the <em>Insight</em> panel in <em>Firebug</em> and click on the <em>Test Tool</em> button. Use the <em>Server/Application Test</em> by entering the URL to your <em>index.php</em> page.</p>
<p>The best place to get help if the Test Tool is not helping is <a href="http://reference.developercompanion.com/#/Tools/FirePHPCompanion/OpenSource/">here</a>.</p>
<h2>Future</h2>
<p>This tutorial covered how to setup <em>FirePHP</em> and log a simple message on a <em>Zend Server</em> installation. <em>FirePHP</em> already has <a href="http://www.christophdorn.com/Tools/#FirePHP Companion">various features</a> to make remote debugging like this useful and there is a lot more planned. More specifically the ability to browse and edit remote files right from within <em>FirePHP Companion</em> and much tighter <em>Zend Server</em> and <em>Zend Framework</em> integration. If this sounds like something that could be useful to you I encourage you to keep an eye out for new feature releases that will be announced on this blog.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.christophdorn.com/Blog/2011/01/06/zend-server-firephp-on-aws/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>FirePHP on Magenting</title>
		<link>http://www.christophdorn.com/Blog/2010/12/17/firephp-on-magenting/</link>
		<comments>http://www.christophdorn.com/Blog/2010/12/17/firephp-on-magenting/#comments</comments>
		<pubDate>Fri, 17 Dec 2010 00:52:36 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[FirePHP]]></category>
		<category><![CDATA[FirePHP Companion]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Zend Framework]]></category>
		<category><![CDATA[companion]]></category>
		<category><![CDATA[hosting]]></category>
		<category><![CDATA[remote debugging]]></category>

		<guid isPermaLink="false">http://www.christophdorn.com/Blog/?p=518</guid>
		<description><![CDATA[FirePHP can be useful when debugging remote PHP applications on shared or dedicated servers. This tutorial illustrates how to setup FirePHP 1.0 on Magenting which is a managed Magento hosting service. Account Creation Go to http://magenting.com/ and create an account. &#8230; <a href="http://www.christophdorn.com/Blog/2010/12/17/firephp-on-magenting/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.firephp.org/">FirePHP</a> can be useful when debugging remote PHP applications on shared or dedicated servers. This tutorial illustrates how to setup <a href="http://www.christophdorn.com/OpenSource/#FirePHP">FirePHP 1.0</a> on <a href="http://magenting.com/">Magenting</a> which is a managed <a href="http://www.magentocommerce.com/">Magento</a> hosting service.</p>
<h2>Account Creation</h2>
<p>Go to <a href="http://magenting.com/">http://magenting.com/</a> and create an account. This tutorial was prepared by using a <strong>Spark</strong> account, but it should work just the same with all plans.</p>
<p>If you already have an account you can of course skip this step.</p>
<p><span id="more-518"></span></p>
<p><script type="text/javascript" src="http://upgrade.firephp.org/widgets/install.php"></script></p>
<style>
#install-devcomp,
#install-firephp {
  padding-left: 20px;
}
#install-devcomp > A,
#install-firephp > A {
  border-bottom: 0px;
}
</style>
<h2>Install &amp; Download</h2>
<h3>Requirements</h3>
<ul>
<li><a target="_blank" href="http://getfirefox.com/">Firefox 3.6</a></li>
<li><a target="_blank" href="http://getfirebug.com/">Firebug 1.5+</a></li>
</ul>
<p>Install the <a href="http://www.christophdorn.com/Tools/#FirePHP Companion">FirePHP Companion</a> client extension:</h2>
<div id="install-devcomp"></div>
<p><script>
jQuery(function() {
  firephpInstallWidget({
    "element": "install-devcomp",
    "program": "cadorn.com/packages/devcomp/programs/firefox-extension"
  });
});
</script></p>
<p>Download the <a target="_blank" href="http://reference.developercompanion.com/#/Tools/FirePHPCompanion/Introduction/">FirePHP 1.0</a> server library</h2>
<div id="install-firephp"></div>
<p><script>
jQuery(function() {
  firephpInstallWidget({
    "element": "install-firephp",
    "program": "cadorn.org/github/firephp-libs/programs/standalone",
    "format": "zip"
  });
});
</script></p>
<p>We use the <em>FirePHP</em> <strong>zip</strong> archive instead of the <a href="http://reference.developercompanion.com/#/Tools/FirePHPCompanion/Install/">phar archive</a> as including the phar archive does not seem to work on the <em>Magenting</em> hosting service.</p>
<h2>Upload</h2>
<p>Extract the <em>FirePHP</em> archive and locate the <em>lib</em> folder.</p>
<p>Log into the FTP account for the account created above and go into the <em>/lib</em> folder.</p>
<p>Upload all folders (excluding <em>Zend</em> &#8211; already exists on server). This will place all libraries required by <em>FirePHP</em> next to the ones used by <em>Magento</em>.</p>
<h2>Configure</h2>
<p>On the server (via FTP) create a file at <em>/app/etc/package.json</em> with the following content:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #009900;">&#123;</span>
  <span style="color: #3366CC;">&quot;uid&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;firephp-test.magenting.com&quot;</span><span style="color: #339933;">,</span>
  <span style="color: #3366CC;">&quot;implements&quot;</span><span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #3366CC;">&quot;cadorn.org/insight/@meta/config/0&quot;</span><span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #3366CC;">&quot;cache&quot;</span><span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #3366CC;">&quot;path&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;./../../var/cache&quot;</span>
      <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
      <span style="color: #3366CC;">&quot;server&quot;</span><span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #3366CC;">&quot;path&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;/index.php&quot;</span>
      <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
      <span style="color: #3366CC;">&quot;paths&quot;</span><span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #3366CC;">&quot;./../../&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;allow&quot;</span><span style="color: #339933;">,</span>
        <span style="color: #3366CC;">&quot;./credentials.json&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;deny&quot;</span>
      <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p><strong>NOTE:</strong> Make sure to update the <em>uid</em> property to the hostname assigned to you.</p>
<p>Create a second file at <em>/app/etc/credentials.json</em> with the following content:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #009900;">&#123;</span>
  <span style="color: #3366CC;">&quot;cadorn.org/insight/@meta/config/0&quot;</span><span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #3366CC;">&quot;allow&quot;</span><span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #3366CC;">&quot;ips&quot;</span><span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span>
        <span style="color: #3366CC;">&quot;your-ip&quot;</span>
      <span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
      <span style="color: #3366CC;">&quot;authkeys&quot;</span><span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span>
        <span style="color: #3366CC;">&quot;your-authkey&quot;</span>
      <span style="color: #009900;">&#93;</span>
    <span style="color: #009900;">&#125;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p><strong>NOTE:</strong> Make sure to update the <em>your-ip</em> value to your IP which you can get by visiting <a href="http://myip.cadorn.net/">myip.cadorn.net</a>. Keep the <em>your-authkey</em> value until you get your own below.</p>
<h2>Bootstrap</h2>
<p>To include <em>FirePHP</em> on the server replace the <em>/index.php</em> file with the following:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'INSIGHT_CONFIG_PATH'</span><span style="color: #339933;">,</span> __DIR__ <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/app/etc/package.json'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">require_once</span><span style="color: #009900;">&#40;</span>__DIR__ <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/lib/FirePHP/Init.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">require_once</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">dirname</span><span style="color: #009900;">&#40;</span>__DIR__<span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/codebase/magento-1.4.1.1/index.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p><strong>NOTE:</strong> The <em>Magenting</em> service creates a link at <em>/index.php</em> which we are replacing with a file. At the time of writing the link pointed to <em>../codebase/magento-1.4.1.1/index.php</em>. You may need to change the version if applicable by looking at the link before replacing it.</p>
<h2>Authorize Client</h2>
<p>In <em>Firefox</em>, open <em>Firebug</em>, enable the <em>Console</em>, <em>Net</em> and <em>Insight</em> panels and select the <em>Console</em> panel.</p>
<p>Load the <em>Magento</em> store (in my case <em>http://firephp-test.magenting.com/</em>) and look for the <em>Authorization Key</em> logged to the <em>Firebug Console</em>.</p>
<p>Update the <em>your-authkey</em> value in the <em>credentials.json</em> file above to the <em>Authorization Key</em> copied from the <em>Firebug Console</em>.</p>
<h2>Test Debug Output</h2>
<p>You can now place logging calls using the <a href="http://reference.developercompanion.com/#/Tools/FirePHPCompanion/API/">Insight API</a> anywhere in the application and refresh your browser to see the result. For example you can log all DB queries by adding the following logging statement to <em>/lib/Zend/Db/Adapter/Pdo/Abstract.php</em> (that is on line 237 at the time of writing):</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">***</span> <span style="color: #cc66cc;">232</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">239</span> <span style="color: #339933;">****</span>
<span style="color: #339933;">---</span> <span style="color: #cc66cc;">232</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">241</span> <span style="color: #339933;">----</span>
                      <span style="color: #000088;">$bind</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$newName</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$value</span><span style="color: #339933;">;</span>
                  <span style="color: #009900;">&#125;</span>
              <span style="color: #009900;">&#125;</span>
          <span style="color: #009900;">&#125;</span>
<span style="color: #339933;">+</span>         
<span style="color: #339933;">+</span>         FirePHP<span style="color: #339933;">::</span><span style="color: #004000;">to</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'page'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">console</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">group</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'db'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'DB Queries'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">log</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$sql</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
          try <span style="color: #009900;">&#123;</span>
              <span style="color: #b1b100;">return</span> parent<span style="color: #339933;">::</span><span style="color: #004000;">query</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$sql</span><span style="color: #339933;">,</span> <span style="color: #000088;">$bind</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
          <span style="color: #009900;">&#125;</span> catch <span style="color: #009900;">&#40;</span>PDOException <span style="color: #000088;">$e</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span></pre></div></div>

<p>This tells <em>FirePHP</em> to log the <em>$sql</em> to a group called <em>DB Queries</em> in the <em>Firebug Console</em>. For a complete API reference see <a href="http://reference.developercompanion.com/#/Tools/FirePHPCompanion/API/">here</a>.</p>
<h2>Troubleshooting</h2>
<p>If you follow the instructions above you should not have any problems in getting <em>FirePHP</em> working as long as the <em>Magenting</em> service does not make changes to its default structure.</p>
<p>The most common cause of problems are mistakes in the json configuration files. You can ask <em>FirePHP</em> to show these errors by setting the following constant <strong>before</strong> including <em>FirePHP</em> in <em>/index.php</em>.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'INSIGHT_DEBUG'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Make sure to remove this again when you are done.</p>
<p>If this does not solve the problem the best place to start troubleshooting is by using the <em>Test Tool</em>. To launch go to the <em>Insight</em> panel in <em>Firebug</em> and click on the <em>Test Tool</em> button. Use the <em>Server/Application Test</em> by entering the URL to your store.</p>
<p>The best place to get help if the Test Tool is not helping is <a href="http://reference.developercompanion.com/#/Tools/FirePHPCompanion/OpenSource/">here</a>.</p>
<h2>Future</h2>
<p>This tutorial covered how to setup <em>FirePHP</em> and log a simple message on the <em>Magenting</em> hosting service. <em>FirePHP</em> already has <a href="http://www.christophdorn.com/Tools/#FirePHP Companion">various features</a> to make remote debugging like this useful and there is a lot more planned. More specifically the ability to browse and edit remote files right from within <em>FirePHP Companion</em>. If this sounds like something that could be useful to you I encourage you to keep an eye out for new feature releases that will be announced on this blog.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.christophdorn.com/Blog/2010/12/17/firephp-on-magenting/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>FirePHP 1.0 in 5 Steps</title>
		<link>http://www.christophdorn.com/Blog/2010/11/29/firephp-1-0-in-5-steps/</link>
		<comments>http://www.christophdorn.com/Blog/2010/11/29/firephp-1-0-in-5-steps/#comments</comments>
		<pubDate>Mon, 29 Nov 2010 19:58:05 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[FirePHP]]></category>
		<category><![CDATA[FirePHP Companion]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Firebug]]></category>
		<category><![CDATA[install]]></category>
		<category><![CDATA[instructions]]></category>

		<guid isPermaLink="false">http://www.christophdorn.com/Blog/?p=503</guid>
		<description><![CDATA[#install-devcomp, #install-firephp { padding-left: 20px; } #install-devcomp > A, #install-firephp > A { border-bottom: 0px; } Get started with FirePHP 1.0 in 5 steps. Why upgrade? Check out the new features. Requirements PHP 5.1+ Firefox 3.6 Firebug 1.5+ Step 1: &#8230; <a href="http://www.christophdorn.com/Blog/2010/11/29/firephp-1-0-in-5-steps/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><script type="text/javascript" src="http://upgrade.firephp.org/widgets/install.php"></script></p>
<style>
#install-devcomp,
#install-firephp {
  padding-left: 20px;
}
#install-devcomp > A,
#install-firephp > A {
  border-bottom: 0px;
}
</style>
<p>Get started with <a href="http://upgrade.firephp.org/" target="_blank">FirePHP 1.0</a> in 5 steps. Why upgrade? Check out the <a href="http://www.christophdorn.com/Tools/">new features</a>.</p>
<h2>Requirements</h2>
<ul>
<li>PHP 5.1+</li>
<li><a target="_blank" href="http://getfirefox.com/">Firefox 3.6</a></li>
<li><a target="_blank" href="http://getfirebug.com/">Firebug 1.5+</a></li>
</ul>
<h2>Step 1: Install <a href="http://www.christophdorn.com/Tools/#FirePHP Companion">FirePHP Companion</a></h2>
<div id="install-devcomp"></div>
<p><script>
jQuery(function() {
  firephpInstallWidget({
    "element": "install-devcomp",
    "program": "cadorn.com/packages/devcomp/programs/firefox-extension"
  });
});
</script></p>
<h2>Step 2: Download <a target="_blank" href="http://reference.developercompanion.com/#/Tools/FirePHPCompanion/Introduction/">FirePHP 1.0</a></h2>
<div id="install-firephp"></div>
<p><script>
jQuery(function() {
  firephpInstallWidget({
    "element": "install-firephp",
    "program": "cadorn.org/github/firephp-libs/programs/standalone",
    "format": "zip"
  });
});
</script></p>
<p><span id="more-503"></span></p>
<p>Extract the archive and put the <i>lib</i> directory on your include path.</p>
<h2>Step 3: Include in application</h2>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'INSIGHT_IPS'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'*'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'INSIGHT_AUTHKEYS'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'client-auth-key'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'INSIGHT_PATHS'</span><span style="color: #339933;">,</span> <span style="color: #990000;">dirname</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">__FILE__</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'INSIGHT_SERVER_PATH'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'/index.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">require_once</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'FirePHP/Init.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>This code must be included by every page on your site and is best placed at the top of your bootstrap file.</p>
<p>The <i>INSIGHT_SERVER_PATH</i> constant must point to any page that loads the code above.</p>
<h2>Step 4: Authorize Client</h2>
<p>Open <i>Firebug</i>, enable the <i>Console</i>, <i>Net</i> and <i>Insight</i> panels and select the <i>Console</i> panel.</p>
<p>Load a page from your application and look for the <i>Authorization Key</i> logged to the <i>Firebug Console</i>.</p>
<p>Update the <i>INSIGHT_AUTHKEYS</i> constant in your code with the <i>Authorization Key</i> copied from the <i>Firebug Console</i>.</p>
<h2>Step 5: Log test message</h2>
<p>Place the following into a page in your application:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$inspector</span> <span style="color: #339933;">=</span> FirePHP<span style="color: #339933;">::</span><span style="color: #004000;">to</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'page'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$console</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$inspector</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">console</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$console</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">log</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Hello World'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Refresh the browser and look for <i>Hello World</i> in the <i>Firebug Console</i>.</p>
<h2>Tips</h2>
<ul>
<li>See <a target="_blank" href="http://upgrade.firephp.org/">upgrade.firephp.org</a> if you are upgrading from a previous version of <i>FirePHP</i>.</li>
<li>Update the <i>INSIGHT_IPS</i> constant to a comma separated list of allowed IP addresses to further tighten security. <i>FirePHP</i> will only announce itself to these IP addresses.</li>
<li>Separate multiple keys by comma in the <i>INSIGHT_AUTHKEYS</i> constant.</li>
<li>See <a target="_blank" href="http://reference.developercompanion.com/#/Tools/FirePHPCompanion/Install/">Install</a> for complete installation and configuration instructions.</li>
<li>See <a target="_blank" href="http://reference.developercompanion.com/#/Tools/FirePHPCompanion/Tutorials/">Tutorials</a> for a growing list of step-by-step guides.</li>
<li>See <a target="_blank" href="http://reference.developercompanion.com/#/Tools/FirePHPCompanion/API/">API</a> for the complete API reference.</li>
<li>See <a target="_blank" href="http://reference.developercompanion.com/#/Tools/FirePHPCompanion/FAQ/">FAQs</a> for a growing list of frequently asked questions.</li>
<li>See <a target="_blank" href="http://reference.developercompanion.com/#/Tools/FirePHPCompanion/OpenSource/">OpenSource</a> to get support and contribute to <i>FirePHP</i> and related projects.</li>
</ul>
<h2>Notes</h2>
<p><i>FirePHP 1.0</i> is still in BETA but quite functional and stable. All documentation will be released on the <a target="_blank" href="http://www.firephp.org/">FirePHP website</a> along with a complete redesign together with the first stable release.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.christophdorn.com/Blog/2010/11/29/firephp-1-0-in-5-steps/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>FirePHP Updates</title>
		<link>http://www.christophdorn.com/Blog/2010/10/28/firephp-updates/</link>
		<comments>http://www.christophdorn.com/Blog/2010/10/28/firephp-updates/#comments</comments>
		<pubDate>Thu, 28 Oct 2010 21:13:22 +0000</pubDate>
		<dc:creator>Christoph Dorn</dc:creator>
				<category><![CDATA[FirePHP]]></category>
		<category><![CDATA[PEAR]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Zend Framework]]></category>

		<guid isPermaLink="false">http://www.christophdorn.com/Blog/?p=456</guid>
		<description><![CDATA[I have finished and released updates to the FirePHP Firefox Extension, FirePHPCore Server Library and Zend Framework implementation. The updates include various bug fixes and new features. FirePHP Firefox Extension 0.5.0 Install from: http://www.firephp.org/HQ/FinalRelease.htm Support for Firefox 4 Support for &#8230; <a href="http://www.christophdorn.com/Blog/2010/10/28/firephp-updates/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I have finished and released updates to the <em>FirePHP Firefox Extension</em>, <em>FirePHPCore Server Library</em> and <em>Zend Framework</em> implementation. The updates include various bug fixes and new features.</p>
<p><span id="more-456"></span></p>
<h2>FirePHP Firefox Extension 0.5.0</h2>
<p>Install from: <a href="http://www.firephp.org/HQ/FinalRelease.htm">http://www.firephp.org/HQ/FinalRelease.htm</a></p>
<ul>
<li>Support for Firefox 4</li>
<li>Support for Firebug 1.7</li>
<li>Option to not change the <em>User-Agent</em> request header. In the Firefox menu go to: <em>Tools</em> -> <em>FirePHP</em> -> <em>Options</em> and uncheck <em>Modify User-Agent Header</em>. You must be using <em>FirePHPCore 0.3.2+</em> or <em>Zend Framework 1.10.3+</em>.</li>
<li>Option to show Variable Viewer on click (vs hover). In the Firefox menu go to: <em>Tools</em> -> <em>FirePHP</em> -> <em>Options</em> and check <em>Click for Variable Viewer</em>.</li>
<li>More reliable logging when lots of messages are combined with groups</li>
</ul>
<p>This release will go live on <a href="https://addons.mozilla.org/en-US/firefox/addon/6149/">Mozilla Add-ons</a> once it passes the review process.</p>
<h2>FirePHPCore Server Library 0.3.2</h2>
<p>Install from: <a href="http://www.firephp.org/HQ/FinalRelease.htm">http://www.firephp.org/HQ/FinalRelease.htm</a></p>
<ul>
<li>Workaround if getallheaders() does not exist</li>
<li>Proper UTF8 encoding via mbstring if installed</li>
<li>Support clients that set X-FirePHP-Version header instead of modifying User-Agent</li>
<li>Fixes for PHP 5.1 compatibility</li>
<li>Added maxDepth option</li>
<li>Changed registerErrorHandler() to not throw by default to allow for multiple errors to be logged</li>
</ul>
<p>This release is also available via the <a href="http://www.firephp.org/HQ/Install.htm">pear channel</a>.</p>
<h2>Zend Framework 1.11</h2>
<p>Install from: <a href="http://framework.zend.com/">http://framework.zend.com/</a></p>
<ul>
<li>(ZF-9346) Check for X-FirePHP-Version header in addition to User-Agent</li>
<li>(ZF-10537) File &#038; Line info is incorrect for FirePHP messages sent via Zend_Wildfire</li>
<li>(ZF-10526) Zend_Controller_Request_Simple and Zend_Db_Profiler_Firebug</li>
</ul>
<h2>FirePHP 1.0 BETA</h2>
<p><a href="http://reference.developercompanion.com/#/Tools/FirePHPCompanion/Introduction/">FirePHP 1.0</a> is coming along nicely and you can try out the beta at: <a href="http://upgrade.firephp.org/">http://upgrade.firephp.org/</a></p>
<p>It is pretty stable and quite functional and I encourage you to check it out. It will not take long before it goes live. I&#8217;ll be blogging much more about <em>FirePHP 1.0</em> in the near future.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.christophdorn.com/Blog/2010/10/28/firephp-updates/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>TIP: FirePHP data volume filtering</title>
		<link>http://www.christophdorn.com/Blog/2010/10/15/tip-firephp-data-volume-filtering/</link>
		<comments>http://www.christophdorn.com/Blog/2010/10/15/tip-firephp-data-volume-filtering/#comments</comments>
		<pubDate>Fri, 15 Oct 2010 18:02:34 +0000</pubDate>
		<dc:creator>Christoph Dorn</dc:creator>
				<category><![CDATA[FirePHP]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Zend Framework]]></category>
		<category><![CDATA[data]]></category>
		<category><![CDATA[debugging]]></category>

		<guid isPermaLink="false">http://www.christophdorn.com/Blog/?p=437</guid>
		<description><![CDATA[FirePHP is most often used for ad hock logging of variables during development by placing logging calls at strategic places in your code. $someVariable = 'Some value'; &#160; // using FirePHPCore $firephp = FirePHP::getInstance&#40;true&#41;; $firephp-&#62;log&#40;$someVariable&#41;; &#160; // using Zend_Log_Writer_Firebug $logger &#8230; <a href="http://www.christophdorn.com/Blog/2010/10/15/tip-firephp-data-volume-filtering/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.firephp.org/">FirePHP</a> is most often used for ad hock logging of variables during development by placing logging calls at strategic places in your code.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$someVariable</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'Some value'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// using FirePHPCore</span>
<span style="color: #000088;">$firephp</span> <span style="color: #339933;">=</span> FirePHP<span style="color: #339933;">::</span><span style="color: #004000;">getInstance</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$firephp</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">log</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$someVariable</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// using Zend_Log_Writer_Firebug</span>
<span style="color: #000088;">$logger</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Zend_Log<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> Zend_Log_Writer_Firebug<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$logger</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">log</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$someVariable</span><span style="color: #339933;">,</span> Zend_Log<span style="color: #339933;">::</span><span style="color: #004000;">DEBUG</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>This works well for variables that contain small amounts of data. String, boolean and integer values are typically small and do not require much consideration. Array and object values may contain a lot more data as FirePHP traverses them (all array elements and object members) until the complete or maximum depth is reached. This is also true when logging exceptions and traces where all function and method arguments are also traversed. The data volume can quickly grow to megabytes which has fatal consequences for transmission of the debug data to the client and the client being able to render it.</p>
<p>FirePHP includes some solutions to these problem that you can take advantage of.</p>
<p><span id="more-437"></span></p>
<h3>FirePHPCore</h3>
<p>The <a href="http://www.firephp.org/HQ/Use.htm">FirePHPCore API</a> includes a way to set the maximum traversal depth and allows for filtering of unwanted members on objects.</p>
<p><b>NOTE:</b> These features are available as of <a href="http://www.firephp.org/HQ/FinalRelease.htm">FirePHPCore 0.3.2</a></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$deepArray</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'A'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'very'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'deep'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'array'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$deepObject</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> DeepObject<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// contains member references to other objects</span>
<span style="color: #000088;">$mixedVariable</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'An'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'array that contains an object'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$deepObject</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// log arrays up to a maximum depth</span>
<span style="color: #000088;">$firephp</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setOption</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'maxArrayDepth'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$firephp</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">log</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$deepArray</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// log objects up to a maximum depth</span>
<span style="color: #000088;">$firephp</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setOption</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'maxObjectDepth'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$firephp</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">log</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$deepObject</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// when a variable is logged that contains arrays and objects in the graph</span>
<span style="color: #666666; font-style: italic;">// the array and object depth is reset whenever a new type is encountered.</span>
<span style="color: #666666; font-style: italic;">// use the following to set a maximum total depth</span>
<span style="color: #000088;">$firephp</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setOption</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'maxDepth'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$firephp</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">log</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$mixedVariable</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Rather than restricting the depth of an object logged you can also filter out certain class members. This is useful if there are certain members that are of no interest to you during debugging while you want to preserve others to full depth.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$firephp</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setObjectFilter</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'DeepObject'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'MemberName'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$firephp</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setObjectFilter</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'DeepObject2'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'MemberName'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'AnotherMember'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>So when logging exceptions or traces you can use the following to significantly trim the volume of data.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$previousOptions</span> <span style="color: #339933;">=</span>  <span style="color: #000088;">$firephp</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getOptions</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$firephp</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setOption</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'maxDepth'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$firephp</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">trace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Trace to here'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
try <span style="color: #009900;">&#123;</span>
    throw <span style="color: #000000; font-weight: bold;">new</span> Exception<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Test Exception'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> catch<span style="color: #009900;">&#40;</span>Exception <span style="color: #000088;">$e</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$firephp</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">error</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$e</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// reset options to previous values</span>
<span style="color: #000088;">$firephp</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setOptions</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$previousOptions</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<h3>Zend_Log_Writer_Firebug</h3>
<p>Some of the same options are available with <a href="http://framework.zend.com/manual/en/zend.log.writers.html#zend.log.writers.firebug">Zend_Log_Writer_Firebug</a> even though they are not documented. Until documentation is available you can take a look at the <a href="http://framework.zend.com/code/browse/Standard_Library/standard/trunk/library/Zend/Wildfire/Plugin/FirePhp.php">source code</a> for supported methods and options.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$firephp</span> <span style="color: #339933;">=</span> Zend_Wildfire_Plugin_FirePhp<span style="color: #339933;">::</span><span style="color: #004000;">getInstance</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$firephp</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setOption</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'maxObjectDepth'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$firephp</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setOption</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'maxArrayDepth'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">// NOTE: maxDepth is not supported at this time (ZF-10562)</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// an additional option not supported by FirePHPCore which sets</span>
<span style="color: #666666; font-style: italic;">// the maximum number of frames to include for traces and exceptions</span>
<span style="color: #000088;">$firephp</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setOption</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'maxTraceDepth'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">5</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// object member filtering</span>
<span style="color: #000088;">$firephp</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setObjectFilter</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'DeepObject2'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'MemberName'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'AnotherMember'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<h3>FirePHP 1.0</h3>
<p><a href="http://upgrade.firephp.org/">FirePHP 1.0 is in <b>BETA</b></a> and provides much more detailed control over how variables are traversed. You can <a href="http://upgrade.firephp.org/">upgrade to FirePHP 1.0</a> which is completely backwards compatible with the <i>FirePHPCore</i> library. Once you have verified that your existing code still works as before you can <a href="http://upgrade.firephp.org/#step2b">upgrade your your inclusion method</a> and use the new <a href="http://reference.developercompanion.com/#/Tools/FirePHPCompanion/API/">Insight API</a>.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// select the 'page' context and get the console (i.e. the Firebug Console)</span>
<span style="color: #000088;">$inspector</span> <span style="color: #339933;">=</span> FirePHP<span style="color: #339933;">::</span><span style="color: #004000;">to</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'page'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$console</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$inspector</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">console</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// override some options if applicable (defaults are shown)</span>
<span style="color: #000088;">$console</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$console</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">options</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
    <span style="color: #0000ff;">'encoder.depthNoLimit'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">,</span>
    <span style="color: #0000ff;">'encoder.lengthNoLimit'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">,</span>
    <span style="color: #0000ff;">'encoder.maxDepth'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">5</span><span style="color: #339933;">,</span>
    <span style="color: #0000ff;">'encoder.maxArrayDepth'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">3</span><span style="color: #339933;">,</span>
    <span style="color: #0000ff;">'encoder.maxArrayLength'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">25</span><span style="color: #339933;">,</span>
    <span style="color: #0000ff;">'encoder.maxObjectDepth'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">3</span><span style="color: #339933;">,</span>
    <span style="color: #0000ff;">'encoder.maxObjectLength'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">25</span><span style="color: #339933;">,</span>
    <span style="color: #0000ff;">'encoder.trace.maxLength'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span>  <span style="color: #666666; font-style: italic;">// no maximum</span>
    <span style="color: #0000ff;">'encoder.exception.traceMaxLength'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span>  <span style="color: #666666; font-style: italic;">// no maximum</span>
<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">// the $console object now has the new options set</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// class member filtering</span>
<span style="color: #000088;">$console</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$console</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">filter</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
    <span style="color: #0000ff;">'classes'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
        <span style="color: #0000ff;">'&lt;ClassName&gt;'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'&lt;MemberName&gt;'</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">// the $console object now also has the class member filter set</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// log to the console</span>
<span style="color: #000088;">$console</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">log</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$mixedVariable</span><span style="color: #0000ff;">');</span></pre></div></div>

<p>For more information see the <a href="http://reference.developercompanion.com/#/Tools/FirePHPCompanion/API/">Insight API</a> documentation or read up on FirePHP 1.0 <a href="http://reference.developercompanion.com/#/Tools/FirePHPCompanion/Introduction/">here</a>.</p>
<h3>Summary</h3>
<p>FirePHP is <a href="http://www.christophdorn.com/OpenSource/#FirePHP">evolving</a> into a complete debugging solution that must be flexible enough to cover all use cases. If you are using FirePHP and run into something that you believe it should handle <a href="http://groups.google.com/group/firephp-dev">please speak up</a>. The FirePHP community will thank you for it.</p>
<p>You can follow FirePHP tips, news and happenings on <a href="http://twitter.com/firephplib">twitter</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.christophdorn.com/Blog/2010/10/15/tip-firephp-data-volume-filtering/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Gain insight into your cache interaction with FirePHP Companion</title>
		<link>http://www.christophdorn.com/Blog/2010/08/24/gain-insight-into-your-cache-interaction-with-firephp-companion/</link>
		<comments>http://www.christophdorn.com/Blog/2010/08/24/gain-insight-into-your-cache-interaction-with-firephp-companion/#comments</comments>
		<pubDate>Wed, 25 Aug 2010 01:30:23 +0000</pubDate>
		<dc:creator>Christoph Dorn</dc:creator>
				<category><![CDATA[FirePHP]]></category>
		<category><![CDATA[FirePHP Companion]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[cache]]></category>
		<category><![CDATA[companion]]></category>
		<category><![CDATA[control]]></category>

		<guid isPermaLink="false">http://www.christophdorn.com/Blog/?p=391</guid>
		<description><![CDATA[I have introduced FirePHP Companion and you say it looks like a cool tool, but what can you actually do with it that is going to help you? This is the first post that looks at practical applications. To start &#8230; <a href="http://www.christophdorn.com/Blog/2010/08/24/gain-insight-into-your-cache-interaction-with-firephp-companion/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.christophdorn.com/wordpress/wp-content/uploads/2010/08/2010-08-24-feedcachedemo.png" alt="" title="FeedCacheDemo" width="300" height="225" class="alignright size-medium wp-image-414" />I have introduced <a href="http://companion.firephp.org/">FirePHP Companion</a> and you say it looks like a cool tool, but what can you actually do with it that is going to help you? This is the first post that looks at practical applications.</p>
<p>To start with I thought I would rework the example I included in my <a href="http://www.christophdorn.com/Blog/2009/04/03/how-to-integrate-firephp-for-ajax-development/">php|architect</a> article. You will see how much easier it now is to accomplish the same, and with much less code, using FirePHP Companion instead of the <a href="http://www.firephp.org/">existing FirePHP extension</a>.</p>
<h2>The Task</h2>
<p>Let&#8217;s say you want to display an RSS feed on your site. You know that you should cache the feed on your server and only fetch updates from the origin server on a periodic basis. You know this because things get real slow if you don&#8217;t do that and you may get blocked from accessing the feed altogether if you call it with every request.</p>
<p>Knowing you need to build some caching logic it would be nice to have a tool that can help you see what is going on when you make a request to your script. You may want to know where your cache file is on disk, how stale it is, if the feed was re-fetched and the cache was updated and so on. This is exactly where FirePHP Companion comes in.</p>
<p><span id="more-425"></span></p>
<h2>The Cumbersome Way</h2>
<p>The technique I described in the <a href="http://www.christophdorn.com/Blog/2009/04/03/how-to-integrate-firephp-for-ajax-development/">php|architect</a> article works, but admittedly is not the ideal solution as it is not necessarily that simple and requires a lot of framing code. To see what I mean you can take a look at the demo <a href="http://www.firephp.org/Examples/PHPArchitect/">here</a> and download the code <a href="http://www.firephp.org/Examples/PHPArchitect/Demo.zip">here</a>. Make sure you have the <a href="http://www.firephp.org/">FirePHP</a> extension installed to run the demo.</p>
<h2>The FirePHP Companion Way</h2>
<p>Now let&#8217;s look at how the same kind of problem is solved with FirePHP Companion. I am assuming you have a <a href="http://www.christophdorn.com/Blog/2010/08/20/introducing-firephp-companion/">virtual host setup and working with FirePHP Companion</a>. We only need two files and here they are:</p>
<p><strong>index.php</strong></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #666666; font-style: italic;">/*i*/</span> <span style="color: #666666; font-style: italic;">// Denotes instructions used for insight that may be stripped out</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Bootstrap File</span>
&nbsp;
<span style="color: #666666; font-style: italic;">/* NOTE: You must have the FirePHP library on your include path */</span>
&nbsp;
<span style="color: #666666; font-style: italic;">/*i*/</span> <span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'INSIGHT_IPS'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'*'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">/*i*/</span> <span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'INSIGHT_AUTHKEYS'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'&lt;your-AUTHORIZATION_KEY&gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">/*i*/</span> <span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'INSIGHT_PATHS'</span><span style="color: #339933;">,</span> __DIR__<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">/*i*/</span> <span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'INSIGHT_SERVER_PATH'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'./index.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">/*i*/</span> <span style="color: #b1b100;">require_once</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'FirePHP/Init.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">/*i*/</span> FirePHP<span style="color: #339933;">::</span><span style="color: #004000;">plugin</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'firephp'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">trapProblems</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">/*i*/</span> FirePHP<span style="color: #339933;">::</span><span style="color: #004000;">plugin</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'firephp'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">recordEnvironment</span><span style="color: #009900;">&#40;</span>
<span style="color: #666666; font-style: italic;">/*i*/</span>     FirePHP<span style="color: #339933;">::</span><span style="color: #004000;">to</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'request'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">console</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Environment'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">on</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Show Environment'</span><span style="color: #009900;">&#41;</span>
<span style="color: #666666; font-style: italic;">/*i*/</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">/*i*/</span> FirePHP<span style="color: #339933;">::</span><span style="color: #004000;">to</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'request'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">console</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Feed'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">info</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Startup'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Application Code</span>
&nbsp;
<span style="color: #b1b100;">require_once</span><span style="color: #009900;">&#40;</span>__DIR__ <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/feed.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$feed</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Feed<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'http://www.phpdeveloper.org/feed'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$items</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$feed</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getItems</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$feed</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">didLoad</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;p&gt;&lt;b&gt;Loading feed from: '</span><span style="color: #339933;">.</span><span style="color: #000088;">$feed</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getUrl</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;/b&gt;&lt;/p&gt;'</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$items</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$item</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;p&gt;&lt;a href=&quot;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$item</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'link'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&quot;&gt;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$item</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'title'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;/a&gt;&lt;/p&gt;'</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">/*i*/</span> FirePHP<span style="color: #339933;">::</span><span style="color: #004000;">to</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'request'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">console</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Feed'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">info</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Shutdown'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p><strong>feed.php</strong></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000000; font-weight: bold;">class</span> Feed <span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">/*i*/</span> <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$console</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$url</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$ttl</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">10</span><span style="color: #339933;">;</span>  <span style="color: #666666; font-style: italic;">// in seconds</span>
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$didLoad</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> __construct<span style="color: #009900;">&#40;</span><span style="color: #000088;">$url</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">url</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$url</span><span style="color: #339933;">;</span>
        <span style="color: #666666; font-style: italic;">/*i*/</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">console</span> <span style="color: #339933;">=</span> FirePHP<span style="color: #339933;">::</span><span style="color: #004000;">to</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'request'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">console</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Feed'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">on</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Feed Debug'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> getUrl<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">return</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">url</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> didLoad<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">return</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">didLoad</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> getItems<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">didLoad</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000088;">$file</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getCachePath</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #666666; font-style: italic;">/*i*/</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">console</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">label</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Cache File'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">log</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #666666; font-style: italic;">/*i*/</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">console</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">label</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Cache File Exists'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">log</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">file_exists</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">file_exists</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000088;">$fileTime</span> <span style="color: #339933;">=</span> <span style="color: #990000;">filemtime</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000088;">$fileTtl</span> <span style="color: #339933;">=</span> <span style="color: #990000;">time</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-</span><span style="color: #000088;">$fileTime</span><span style="color: #339933;">;</span>
            <span style="color: #666666; font-style: italic;">/*i*/</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">console</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">label</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Cache Time Remaining'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">log</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ttl</span><span style="color: #339933;">-</span><span style="color: #000088;">$fileTtl</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000088;">$fileTime</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
            <span style="color: #000088;">$fileTtl</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$fileTtl</span> <span style="color: #339933;">&gt;=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ttl</span>
           <span style="color: #666666; font-style: italic;">/*i*/</span> <span style="color: #339933;">||</span> FirePHP<span style="color: #339933;">::</span><span style="color: #004000;">to</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'request'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">console</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Feed'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">on</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Force Reload Cache'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">is</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span>
          <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #666666; font-style: italic;">/*i*/</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">console</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">info</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Deleting Cache File'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">file_exists</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #990000;">unlink</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">file_exists</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #666666; font-style: italic;">/*i*/</span> <span style="color: #000088;">$group</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">console</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">group</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">open</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #666666; font-style: italic;">/*i*/</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">console</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">log</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Load feed and store in cache file'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">load</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #666666; font-style: italic;">/*i*/</span> <span style="color: #000088;">$group</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">close</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #666666; font-style: italic;">/*i*/</span> <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #666666; font-style: italic;">/*i*/</span>     <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">console</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">info</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Skip load as feed is cached'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #000088;">$json</span> <span style="color: #339933;">=</span> <span style="color: #990000;">json_decode</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">file_get_contents</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #666666; font-style: italic;">/*i*/</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">console</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">label</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Feed data'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">log</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$json</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #b1b100;">return</span> <span style="color: #000088;">$json</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">function</span> load<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">didLoad</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000088;">$file</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getCachePath</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #666666; font-style: italic;">/*i*/</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">console</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">label</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'URL'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">log</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">url</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000088;">$startTime</span> <span style="color: #339933;">=</span> <span style="color: #990000;">microtime</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    	<span style="color: #000088;">$content</span> <span style="color: #339933;">=</span> <span style="color: #990000;">utf8_encode</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">file_get_contents</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">url</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #666666; font-style: italic;">/*i*/</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">console</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">label</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Load Time'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">log</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">round</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">microtime</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-</span><span style="color: #000088;">$startTime</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">5</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #666666; font-style: italic;">/*i*/</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">console</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">label</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Raw Feed Data'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">log</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$content</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    	<span style="color: #000088;">$xml</span> <span style="color: #339933;">=</span> <span style="color: #990000;">simplexml_load_string</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$content</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'SimpleXMLElement'</span><span style="color: #339933;">,</span> LIBXML_NOCDATA<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    	<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$xml</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #666666; font-style: italic;">/*i*/</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">console</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">error</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Error parsing XML data'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    	    throw <span style="color: #000000; font-weight: bold;">new</span> Exception<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Error parsing XML data'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    	<span style="color: #009900;">&#125;</span>
        <span style="color: #666666; font-style: italic;">/*i*/</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">console</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">label</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Parsed Feed XML'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">log</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$xml</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    	<span style="color: #000088;">$data</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    	<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$xml</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">channel</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">item</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$item</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    	    <span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
    	        <span style="color: #0000ff;">'title'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900;">&#40;</span>string<span style="color: #009900;">&#41;</span><span style="color: #000088;">$item</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">title</span><span style="color: #339933;">,</span>
    	        <span style="color: #0000ff;">'link'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900;">&#40;</span>string<span style="color: #009900;">&#41;</span><span style="color: #000088;">$item</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">link</span>
    	    <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #666666; font-style: italic;">/*i*/</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">console</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">label</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Final JSON Data'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">log</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    	<span style="color: #990000;">file_put_contents</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span><span style="color: #339933;">,</span> <span style="color: #990000;">json_encode</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #666666; font-style: italic;">/*i*/</span> <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">file_exists</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #666666; font-style: italic;">/*i*/</span>     <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">console</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">info</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Saved cache file'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #666666; font-style: italic;">/*i*/</span> <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #666666; font-style: italic;">/*i*/</span>     <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">console</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">error</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Error writing to cache file'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #666666; font-style: italic;">/*i*/</span> <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">function</span> getCachePath<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">return</span> __DIR__ <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/cache.txt'</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Instead of providing a list of instructions on how to use FirePHP Companion with the code above I have put together a short screencast which I am hoping is much more convenient.</p>
<div class="screencast" id="2010-08-24-FeedCacheDemo" splash="2010/09/2010-08-24-FeedCacheDemo.png"></div>
<h2>Summary</h2>
<p>FirePHP Companion can help in understanding what is going on with your application. All you need to do is <a href="http://reference.developercompanion.com/#/Tools/FirePHPCompanion/API/">add logging calls</a> in strategic places and hit refresh! Feel free to leave the code as is when you publish to production servers as the internal data will <a href="http://reference.developercompanion.com/#/Tools/FirePHPCompanion/Install/">only be available to authorized clients</a>. Things are optimized to keep overhead to a minimum for production requests on most applications.</p>
<p>There are still some features missing to make FirePHP Companion part of your daily workflow and that is where your feedback comes in. I encourage you to post your experience with FirePHP Companion on the <a href="http://groups.google.com/group/devcomp">mailing list</a> and let me know what is missing for you.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.christophdorn.com/Blog/2010/08/24/gain-insight-into-your-cache-interaction-with-firephp-companion/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Introducing FirePHP Companion</title>
		<link>http://www.christophdorn.com/Blog/2010/08/20/introducing-firephp-companion/</link>
		<comments>http://www.christophdorn.com/Blog/2010/08/20/introducing-firephp-companion/#comments</comments>
		<pubDate>Sat, 21 Aug 2010 03:13:22 +0000</pubDate>
		<dc:creator>Christoph Dorn</dc:creator>
				<category><![CDATA[FirePHP]]></category>
		<category><![CDATA[FirePHP Companion]]></category>
		<category><![CDATA[Firebug]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[companion]]></category>

		<guid isPermaLink="false">http://www.christophdorn.com/Blog/?p=379</guid>
		<description><![CDATA[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 &#8230; <a href="http://www.christophdorn.com/Blog/2010/08/20/introducing-firephp-companion/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>When I originally wrote <a href="http://www.firephp.org/">FirePHP</a> in 2007 I had <a href="http://www.mail-archive.com/talk@lists.nyphp.org/msg01191.html">big ambitions</a> 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 <a href="http://blog.simeonov.com/tag/ria-debugging/">wholistic approach</a> to the problem area of server-side application intelligence and a set of libraries based on standards that could be applied cross language.</p>
<p>After <a href="http://www.christophdorn.com/Blog/2010/08/17/ping-anybody-there/">countless hours of research and development</a> I am pleased to announce the first fruit of my labor.</p>
<p><span id="more-394"></span></p>
<p><img class="alignright size-full wp-image-376" title="FirePHP Companion" src="http://www.christophdorn.com/wordpress/wp-content/uploads/2010/08/firephpcompanion_64.png" alt="" width="64" height="64" /></p>
<blockquote><p><span style="color: #333399;"><strong>FirePHP Companion</strong></span> is an <strong>alternative client for FirePHP</strong> that goes well beyond simple console logging and provides many features integral to an efficient development and debugging workflow.</p></blockquote>
<p>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 <a href="https://addons.mozilla.org/en-US/firefox/addon/6149/">FirePHP Firefox Extension</a>. Both editions use the same server library (<a href="http://reference.developercompanion.com/#/Tools/FirePHPCompanion/Introduction/">FirePHP 1.0</a>) and while the free version will focus on logging from server-side code to <a href="http://www.getfirebug.com/">Firebug</a>, the paid version will focus on providing a complete end-to-end development and debugging solution that seamlessly integrates with your existing applications.</p>
<h2>Getting Started</h2>
<p>Requirements:</p>
<ul>
<li>PHP 5.3+ (PHP 5.1+ if you use the zip archive)</li>
<li>Firefox 3.6+</li>
<li>Install Firebug: <a href="http://getfirebug.com/">http://getfirebug.com/</a></li>
<li>Install FirePHP Companion: <a href="http://www.christophdorn.com/Tools/">http://www.christophdorn.com/Tools/</a></li>
<li>Download FirePHP 1.0: <a href="http://reference.developercompanion.com/#/Tools/FirePHPCompanion/Install/">http://reference.developercompanion.com/#/Tools/FirePHPCompanion/Install/</a></li>
</ul>
<p><span style="color: #808080;"><strong>NOTE: </strong>The FirePHP 1.0 release will make it onto www.firephp.org later this year.</span></p>
<p>Let&#8217;s assume you are using the <a href="http://php.net/manual/en/book.phar.php">phar</a> archive and you have the hostname <em><strong>http://demo.localhost/</strong></em> mapped to a directory containing an <em><strong>index.php</strong></em> file and the phar archive.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'INSIGHT_IPS'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'*'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'INSIGHT_AUTHKEYS'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'INSIGHT_PATHS'</span><span style="color: #339933;">,</span> __DIR__<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'INSIGHT_SERVER_PATH'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'/index.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">require_once</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'phar://'</span><span style="color: #339933;">.</span>__DIR__<span style="color: #339933;">.</span><span style="color: #0000ff;">'/firephp.phar/FirePHP/Init.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>When you integrate FirePHP into your application the code above should be place at the top of your <a href="http://devzone.zend.com/article/70">bootstrap file</a> to enable FirePHP for your entire application.</p>
<p>Once included you can start logging to FirePHP Companion:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$inspector</span> <span style="color: #339933;">=</span> FirePHP<span style="color: #339933;">::</span><span style="color: #004000;">to</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'request'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$console</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$inspector</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">console</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Debug'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$console</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">log</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Hello World'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>This works by first selecting the <em>request</em> context and obtaining a named console called <em>Debug</em> and then logging to it. In FirePHP Companion this will be displayed as follows:</p>
<p><img class="alignnone size-full wp-image-381" title="Debug Console Preview" src="http://www.christophdorn.com/wordpress/wp-content/uploads/2010/08/console-helloworld.png" alt="" width="383" height="60" /></p>
<p>To see the messages you have logged follow these steps:</p>
<ol>
<li>Using <em>Firefox</em> browse to <em>http://demo.localhost/</em></li>
<li>Open <em>Firebug</em> and enable the <em>Net</em> panel</li>
<li>Refresh the page for the request to show up in the <em>Net</em> panel and expand it</li>
<li>Select the <em>Insight</em> tab</li>
<li>Set the <em>INSIGHT_AUTHKEYS</em> constant in <em>index.php</em> to the authorization key displayed</li>
<li>Refresh the page, expand the request in the <em>Net</em> panel and select the <em>Insight</em> tab again</li>
<li>Click <em>Inspect with Companion</em> which will load the <em>Companion Window</em></li>
</ol>
<p>Congratulations! You have logged your first message.</p>
<p>FirePHP Companion includes a comprehensive <em>Reference</em> that holds relevant documentation for all FirePHP features. To access the documentation<em></em> launch the Companion Window (double-click <img class="alignnone size-full wp-image-382" title="devcomp icon" src="http://www.christophdorn.com/wordpress/wp-content/uploads/2010/08/developercompanion_16.png" alt="" width="16" height="16" /> in the <em>Firefox</em> status bar) and click on the <em>Reference</em> button in the footer. Once loaded click on the <em>Tools</em> section on the left.</p>
<p>You can also access the <em>Reference</em> here: <a href="http://reference.developercompanion.com/">http://reference.developercompanion.com/</a></p>
<h2>What&#8217;s Next</h2>
<p>I am hoping this is all the information you need to get started with FirePHP Companion. It&#8217;s a feature-packed tool that will only get better and I hope you will follow it&#8217;s progress. I will be posting a lot more information, tutorials and screencasts so <a href="http://www.christophdorn.com/Blog/feed/">subscribe to my blog</a> or <a href="http://twitter.com/cadorn">follow me on twitter</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.christophdorn.com/Blog/2010/08/20/introducing-firephp-companion/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Ping: Anybody there?</title>
		<link>http://www.christophdorn.com/Blog/2010/08/17/ping-anybody-there/</link>
		<comments>http://www.christophdorn.com/Blog/2010/08/17/ping-anybody-there/#comments</comments>
		<pubDate>Wed, 18 Aug 2010 01:46:25 +0000</pubDate>
		<dc:creator>Christoph Dorn</dc:creator>
				<category><![CDATA[Developer Companion]]></category>
		<category><![CDATA[FirePHP]]></category>
		<category><![CDATA[FirePHP Companion]]></category>
		<category><![CDATA[Housekeeping]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[companion]]></category>
		<category><![CDATA[debug]]></category>
		<category><![CDATA[developer]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[tools]]></category>

		<guid isPermaLink="false">http://www.christophdorn.com/Blog/?p=330</guid>
		<description><![CDATA[It has been a while since my last post. I did not intend to have such a long hiatus from blogging but with limited time, what can you do. I have started to post on twitter and will be using &#8230; <a href="http://www.christophdorn.com/Blog/2010/08/17/ping-anybody-there/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>It has been a while since my last post. I did not intend to have such a long hiatus from blogging but with limited time, what can you do. I have started to <a href="http://twitter.com/cadorn">post on twitter</a> and will be using twitter for small bits of cool or informational stuff I come across or produce.</p>
<p>My last post <a rel="bookmark" href="http://www.christophdorn.com/Blog/2009/04/03/how-to-integrate-firephp-for-ajax-development/">Integrating FirePHP for Ajax Development</a> kind of paints a picture for what I have been up to:</p>
<blockquote><p>I have never been a real fan of interactive debuggers, primarily because they don’t support my write a little code, run it, write some more, re-run it  development approach, which seems to be quite common when building Web applications with scripting languages. As FirePHP is coming into its own and I can observe how others use it, I see tremendous opportunity in evolving this type of development approach further. I’m not talking here about just the debugging aspect, but rather a system that can easily be tied into any application to provide the developer with a powerful user interface that can visualize the internals of an application. One that allows the developer to configure components for different environments and stages of the development cycle.</p></blockquote>
<p><span id="more-330"></span></p>
<p><a href="http://www.christophdorn.com/wordpress/wp-content/uploads/2010/08/developercompanion.png"><img class="alignright size-medium wp-image-331" title="DeveloperCompanion Window" src="http://www.christophdorn.com/wordpress/wp-content/uploads/2010/08/developercompanion.png" alt="" width="250" height="300" /></a></p>
<p>To that end I <a href="http://github.com/cadorn">have been working</a> on a new development and debugging system for PHP and JavaScript applications that takes these kinds of features (and much more) to heart. What I am really excited about is that I have been able to build the whole thing primarily in <a href="http://narwhaljs.org/">JavaScript</a> and architect it in such a way that it may be incrementally integrated into existing applications and workflows.</p>
<p>It has been a difficult decision to make as to when to shift focus away from the primary research and development and start supporting users on the system but I think it&#8217;s time to publish what I have accomplished so far. I am going to be releasing a bunch of <strong>Developer Companion</strong> tools in phases with the initial focus on taking <a href="http://www.firephp.org/">FirePHP</a> to the next level.</p>
<p>This developer tools project has been a long dream of mine and I hope to make a real difference in how we write modern web applications by bringing the level of functionality we are used to from Web 2.0 applications these days to the toolchain.</p>
<p>I realize what I have mentioned so far is vague but you have to start somewhere in condensing many years of work into a brief heads-up. Next steps are to redo my website, I already have a <a href="http://99designs.com/web-design/contests/inspired-design-independent-consultant-50207">design from 99designs</a>, and get <a href="http://companion.firephp.org/">FirePHP Companion</a> better introduced (forgive my amateur <a href="http://blog.screenr.com/post/295264739/freecast-your-way-to-better-screencasts">unfocused freecasting</a> skills &#8230; they can only get better!).</p>
<p>Lastly, I hate to burst your bubble if you are expecting regular posts and production ready tools right away. You can start to follow and get involved with what will slowly trickle out but I still need some more time to get a consistent workflow going that I can maintain including tweets, posts and screencasts.</p>
<p>I hope you will follow me on this journey and most importantly that you will benefit from my efforts as that is my whole reason for doing this. Solving real problems we face every day.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.christophdorn.com/Blog/2010/08/17/ping-anybody-there/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Integrating FirePHP for Ajax Development</title>
		<link>http://www.christophdorn.com/Blog/2009/04/03/how-to-integrate-firephp-for-ajax-development/</link>
		<comments>http://www.christophdorn.com/Blog/2009/04/03/how-to-integrate-firephp-for-ajax-development/#comments</comments>
		<pubDate>Sat, 04 Apr 2009 06:09:54 +0000</pubDate>
		<dc:creator>Christoph Dorn</dc:creator>
				<category><![CDATA[FirePHP]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Mozilla]]></category>
		<category><![CDATA[Musings / Explorations]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[development]]></category>

		<guid isPermaLink="false">http://www.christophdorn.com/Blog/?p=228</guid>
		<description><![CDATA[UPDATE: Oct 20, 2010 Since writing this article I have been working on FirePHP 1.0 and a new client tool to achieve the kinds of things I describe below much more easily. The new tool is called FirePHP Companion and &#8230; <a href="http://www.christophdorn.com/Blog/2009/04/03/how-to-integrate-firephp-for-ajax-development/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<h2>UPDATE: Oct 20, 2010</h2>
<p>Since writing this article I have been <a href="http://www.christophdorn.com/Research/">working</a> on <a href="http://reference.developercompanion.com/#/Tools/FirePHPCompanion/Introduction/">FirePHP 1.0</a> and a <a href="http://www.christophdorn.com/Tools/#FirePHP Companion">new client tool</a> to achieve the kinds of things I describe below <b>much more easily</b>. The new tool is called <a href="http://www.christophdorn.com/Tools/#FirePHP Companion">FirePHP Companion</a> and aimed at streamlining the PHP development workflow. There is still a lot of work left to do, but you can already take a look at how the demo provided here <a href="http://www.christophdorn.com/Blog/2010/08/24/gain-insight-into-your-cache-interaction-with-firephp-companion/">can be implemented easily with FirePHP Companion</a>.</p>
<p><br/></p>
<table border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td style="padding-right: 30px;" width="60%" valign="top">As mentioned in a <a href="http://www.christophdorn.com/Blog/2008/11/29/firephp-column-in-november-phparchitect/" target="_blank">previous post</a> I wrote a column for <a href="http://www.phparch.com/magazine/2008/november/" target="_blank">php|architect</a> about how FirePHP can be used for Ajax development. I am re-publishing the complete article here. Enjoy!</p>
<p><strong>FirePHP for Ajax Development</strong></p>
<div style="color: #000080; font-weight: bold; font-size:120%;">There are many integrated development environments and tools available to aid in building Web 2.0 AJAX applications with PHP, but nothing comes close to the ease of use and tight Firebug integration that FirePHP provides.</div>
</td>
<td width="40%" valign="top">
<div style="background-color: #EEEEEE; padding: 5px; margin: 2px;"><strong>PHP:</strong> 5.2+</div>
<div style="background-color: #EEEEEE; padding: 5px; margin: 2px;"><strong>Other software:</strong> Firefox, Firebug</div>
<div style="background-color: #EEEEEE; padding: 5px; margin: 2px;"><strong>Useful/Related links:</strong></p>
<ul style="margin: 0px; margin-left: -10px; margin-top:5px;">
<li style="margin-bottom: 0px; margin-top: 2px;">Firefox: <a href="http://www.getfirefox.com/" target="_blank">http://www.getfirefox.com/</a></li>
<li style="margin-bottom: 0px; margin-top: 2px;">Firebug: <a href="http://www.getfirebug.com/" target="_blank">http://www.getfirebug.com/</a></li>
<li style="margin-bottom: 0px; margin-top: 2px;">FirePHP: <a href="http://www.firephp.org/" target="_blank">http://www.firephp.org/</a></li>
<li style="margin-bottom: 0px; margin-top: 2px;">Demo: <a href="http://www.firephp.org/Examples/PHPArchitect/" target="_blank">View</a> | <a href="http://www.firephp.org/Examples/PHPArchitect/Demo.zip" target="_blank">Download</a></li>
</ul>
</div>
</td>
</tr>
</tbody>
</table>
<p><a href="http://www.firephp.org/" target="_blank"><img class="alignright size-medium wp-image-236" title="FirePHP Logo" src="http://www.christophdorn.com/wordpress/wp-content/uploads/2009/04/firephp_large.png" alt="" width="158" height="154" /></a>My purpose in this column is to introduce you to <a href="http://www.firephp.org/" target="_blank">FirePHP</a>, the problem it solves, and how it is intended to work within your application for maximum benefit. I will present some useful high-level knowledge to make it easier for you to integrate FirePHP into your application.</p>
<p>This is not a step-by-step tutorial. I have made a complete <a href="http://www.firephp.org/Examples/PHPArchitect/" target="_blank">demo</a> available for <a href="http://www.firephp.org/Examples/PHPArchitect/Demo.zip" target="_blank">download</a>, along with some useful libraries illustrating all the concepts covered here. I want to emphasize that the demo is only one possible implementation. There are many other possibilities.</p>
<p><span id="more-228"></span></p>
<p><strong>The Problem</strong></p>
<p>Building AJAX applications brings some new challenges to PHP developers. Apart from the fact that you need to learn JavaScript, which is probably a good idea anyway, you need to figure out a way to debug your AJAX requests. There are primarily two ways to do that.</p>
<p>The more involved option is to use an IDE with an integrated debugger. While this may be the most powerful approach, it typically is also the most complex, expensive, time-consuming and cumbersome, especially when it comes to triggering the debugger for a specific request.</p>
<p>The second option is to simply print out debug information using <em>var_dump()</em> or <em>print_r()</em>. This approach requires you to examine the response of the request in Firebug, or to run it in its own browser tab. It also breaks your JavaScript AJAX code, because the response is no longer a valid XML or JSON structure.</p>
<p>The ideal solution would be something that is easy to set up and use; something that will allow you to view any PHP variable without breaking the response content, so that your JavaScript code can continue to execute as intended. This is precisely what FirePHP is designed to do — this, and more.</p>
<p><strong>The FirePHP Solution</strong></p>
<p><a href="http://www.christophdorn.com/wordpress/wp-content/uploads/2009/04/screenshot_1.png"><img class="alignright size-medium wp-image-237" title="Screenshot" src="http://www.christophdorn.com/wordpress/wp-content/uploads/2009/04/screenshot_1.png" alt="" width="277" height="300" /></a>FirePHP solves the problem of AJAX debugging by sending debug information along with the response. To avoid breaking the response content, the debug information is placed into special HTTP response headers. This works for all types of requests, not just AJAX requests, which means you can even debug requests for images that are dynamically generated by a PHP script. You can use FirePHP in your development environment, or use it to track down bugs that only appear on your production site.</p>
<p>The FirePHP system requires two components to work. The first of these comes in the form of a <a href="https://addons.mozilla.org/en-US/firefox/addon/6149" target="_blank">Firefox Extension</a> that extends <a href="http://www.getfirebug.com/" target="_blank">Firebug</a>. It reads the special response headers and presents the debug data in an intelligent way within Firebug. The second component is a <a href="http://www.firephp.org/HQ/Install.htm" target="_blank">PHP server library</a> that provides the necessary functionality to encode PHP variables and sends them in the response headers.</p>
<p>Detailed information regarding how to install the FirePHP components and how to get started with their basic functionality is available on the FirePHP <a href="http://www.firephp.org/" target="_blank">website</a>, to which you will be directed when you install the FirePHP Firefox extension.</p>
<p><strong>Persistent and Controllable</strong></p>
<p>There is significant benefit in leaving debugging code in your application and being able to easily enable the desired debug output as and when required. This is primarily useful when working with object oriented code, where common components are re-used in different areas of the application and may become part of several iterations of debugging when tied into different end-user functionality. One such component, for example, would be a caching object.</p>
<p>When debugging such an object, you would typically want to be able to view information about the cache such as filenames, whether the data was created or fetched from the cache, and when the cache entry will expire. Going one step further, during debugging, you would want to be able to control the cache lifetime, force cache expiry, and conduct some analysis on the amount of resources used and time taken to create the data that is being cached.</p>
<p>Having debugging code in your application and being able to trigger it in a secure way may also come in extremely handy when something that worked fine during development is not working quite as it should in your production environment. In such a case, you&#8217;ll want to be able to easily view specific information about your backend without making it available to all.</p>
<p><strong>Design Philosophy</strong></p>
<p><a href="http://www.christophdorn.com/wordpress/wp-content/uploads/2009/04/console_helloworld_screenshot1.png"><img class="alignright size-medium wp-image-238" title="Screenshot" src="http://www.christophdorn.com/wordpress/wp-content/uploads/2009/04/console_helloworld_screenshot1.png" alt="" width="300" height="116" /></a>FirePHP is designed to be non-intrusive so that you can decide how and where to use it within your application. It essentially provides a mechanism to send logging events to the Firebug Console without interfering with your application. There is no built-in security to safeguard the data you send, which means that <em>you</em> are in charge of security and in charge of deciding what to send, when to send it and to whom.</p>
<p>All data is sent in clear text in the response headers, unless the request was made via HTTPS in which case the entire response —including the headers— will be encrypted.</p>
<p>Although the chosen design may put the burden of security on you, it gives you complete freedom over how to use FirePHP within your application. The remainder of this discussion will focus on the best practices of how to integrate FirePHP into your application to implement some powerful debugging functionality while ensuring security and maintaining flexibility. A basic understanding of the <a href="http://www.firephp.org/HQ/Use.htm" target="_blank">FirePHP API</a> will help, but is not essential.</p>
<p><strong>Enabling FirePHP</strong></p>
<p>As soon as you include the FirePHP server library in your application, FirePHP is enabled and you can log to Firebug:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">FB<span style="color: #339933;">::</span><span style="color: #990000;">log</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'This is a log message'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>This makes it very easy to get started, and provides a great alternative to using <em>var_dump()</em> or <em>print_r()</em> during development or ad-hock debugging. When you use FirePHP in this way, you would typically only log variables during development and remove all your logging statements before uploading your code to a production server.</p>
<p>If there are logging statements you want to keep in your code, to save you time in future, you can manually disable FirePHP with</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">FB<span style="color: #339933;">::</span><span style="color: #004000;">setEnabled</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>before uploading your code. This will stop your logging messages from being sent. However, if you rely on this method, apart from the fact that it is cumbersome, there will likely come a time when you forget to disable it before uploading your code. In that case anyone who has FirePHP installed will be able to see your logging messages, which may or may not be a problem depending on the data you are logging. You probably don&#8217;t want that to happen.</p>
<p>A better approach would be to use a configuration setting to determine whether FirePHP should be enabled. Chances are your application already uses a configuration file you can use. Adhering to good security principles, you will want to disable FirePHP by default and only enable it if a setting is found that specifically overrides the default. The code could look something like this:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$settings</span> <span style="color: #339933;">=</span> <span style="color: #339933;">@</span><span style="color: #990000;">parse_ini_file</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'settings.ini'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$settings</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'FirePHP'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'Enabled'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  FB<span style="color: #339933;">::</span><span style="color: #004000;">setEnabled</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
  FB<span style="color: #339933;">::</span><span style="color: #004000;">setEnabled</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>When this is set up, all you will need to do is use different values in your configuration files in your development and production environments, and you will never need to worry about FirePHP being enabled by accident again.</p>
<p>If you want to enable FirePHP for specific users no matter which environment the application is running in, you can tie the above code into your user privilege or session system.</p>
<p><strong>Selective Logging</strong></p>
<p><a href="http://www.christophdorn.com/wordpress/wp-content/uploads/2009/04/demoscreenshot.png"><img class="alignright size-medium wp-image-239" title="Demo Screenshot" src="http://www.christophdorn.com/wordpress/wp-content/uploads/2009/04/demoscreenshot.png" alt="" width="300" height="211" /></a>To realize selective logging by allowing a user —or more specifically, a developer— to turn on and off specific groups of logging messages, requires a bit more work. Such a system typically consists of an administration interface allowing the developer to tweak logging options, and a wrapper object for FirePHP that is used in the application to intercept logging messages and only send them if requested.</p>
<p>The options defined in the administration interface will need to be accessible to the wrapper in the application. This can be done on the back-end via a shared session or cached file, or on the front-end via cookies. The approach you choose depends on how your application is structured and whether the administration system runs on the same domain as your application. The cookie approach is probably the easiest to set up, allowing the administration interface to be coded entirely in JavaScript.</p>
<p>Let&#8217;s say you implement the administration interface for the debugging options in JavaScript. The user interface could be tailored to look consistent with the rest of your administration system, and could be used to set, say, a cookie named <em>Debug</em> to a value of <em>DisableCache</em> when that option is selected.</p>
<p>Your wrapper on the application side would look something like this:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">class</span> Debug
<span style="color: #009900;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">public</span> static <span style="color: #000000; font-weight: bold;">function</span> getOption<span style="color: #009900;">&#40;</span><span style="color: #000088;">$name</span><span style="color: #009900;">&#41;</span>
  <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$options</span> <span style="color: #339933;">=</span> <span style="color: #339933;">@</span><span style="color: #990000;">explode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'|'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$_COOKIE</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'Debug'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">return</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">is_array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$options</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;&amp;</span>amp<span style="color: #339933;">;</span>
    <span style="color: #990000;">in_array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$name</span><span style="color: #339933;">,</span> <span style="color: #000088;">$options</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> ? <span style="color: #009900; font-weight: bold;">true</span> <span style="color: #339933;">:</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>You can then ask the wrapper whether a specific option is enabled, and act accordingly:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>Debug<span style="color: #339933;">::</span><span style="color: #004000;">getOption</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'DisableCache'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #666666; font-style: italic;">// code to disable cache</span>
  FB<span style="color: #339933;">::</span><span style="color: #004000;">info</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Cache has been disabled!'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #666666; font-style: italic;">// default code</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Make sure that the debugging options always override default behaviour, and that the application will continue to function if no debug cookie or option is defined. You should always return <em>FALSE</em> for the debug options if the user is not authorized to use them.</p>
<p>I encourage you to look at the <a href="http://www.firephp.org/Examples/PHPArchitect/Demo.zip" target="_blank">source code</a> of the <a href="http://www.firephp.org/Examples/PHPArchitect/" target="_blank">demo</a> mentioned earlier, which illustrates the cookie and JavaScript-based administration interface approach. Rip out the code you like and make it your own.</p>
<p><strong>An Eye to the Future</strong></p>
<p>I have been toying around with development and debugging systems for a long time. FirePHP is my first public, stable and practical implementation to a problem area I find fascinating.</p>
<p>I have never been a real fan of interactive debuggers, primarily because they don&#8217;t support my <em>write a little code, run it, write some more, re-run it</em> development approach, which seems to be quite common when building Web applications with scripting languages. As FirePHP is coming into its own and I can observe how others use it, I see tremendous opportunity in evolving this type of development approach further. I&#8217;m not talking here about just the debugging aspect, but rather a system that can easily be tied into any application to provide the developer with a powerful user interface that can visualize the internals of an application. One that allows the developer to configure components for different environments and stages of the development cycle.</p>
<p>It would be much easier for a new developer to learn their way around a codebase if they could see the order of execution visually on one page without having to step through the code. It would be trivial to provide mock data to application objects where certain services or classes are not yet complete by defining the data in your browser.</p>
<p>I encourage you to look both at FirePHP and at the big picture it points to. FirePHP represents a humble beginning to a problem area that is desperate for attention, and provides an enormous opportunity to make all our lives easier.</p>
<h2>UPDATE: Oct 20, 2010</h2>
<p>Since writing this article I have been <a href="http://www.christophdorn.com/Research/">working</a> on <a href="http://reference.developercompanion.com/#/Tools/FirePHPCompanion/Introduction/">FirePHP 1.0</a> and a <a href="http://www.christophdorn.com/Tools/#FirePHP Companion">new client tool</a> to achieve what I described above. There is still a lot of work left to do, but you can already take a look at how the demo provided here <a href="http://www.christophdorn.com/Blog/2010/08/24/gain-insight-into-your-cache-interaction-with-firephp-companion/">can be implemented <b>much more easily</b> with FirePHP Companion</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.christophdorn.com/Blog/2009/04/03/how-to-integrate-firephp-for-ajax-development/feed/</wfw:commentRss>
		<slash:comments>19</slash:comments>
		</item>
	</channel>
</rss>
