<?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>Phil Brown&#039;s Web Development Blog &#187; bootstrap</title>
	<atom:link href="http://blog.philipbrown.id.au/tag/bootstrap/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.philipbrown.id.au</link>
	<description></description>
	<lastBuildDate>Mon, 24 May 2010 05:11:00 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Extending Zend Framework Application Resource Plugins</title>
		<link>http://blog.philipbrown.id.au/2009/06/extending-zend-framework-application-resource-plugins/</link>
		<comments>http://blog.philipbrown.id.au/2009/06/extending-zend-framework-application-resource-plugins/#comments</comments>
		<pubDate>Tue, 30 Jun 2009 01:21:50 +0000</pubDate>
		<dc:creator>Phil</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Zend Framework]]></category>
		<category><![CDATA[bootstrap]]></category>
		<category><![CDATA[resource plugins]]></category>

		<guid isPermaLink="false">http://morecowbell.net.au/?p=89</guid>
		<description><![CDATA[With the arrival of Zend Framework version 1.8 came the application resource plugins. These nifty little classes help bootstrap your application&#8217;s resources (views, layouts, database connections, etc). The default behaviour is suitable for most needs however, occasionally, you&#8217;re going to want to perform some extra functionality.
Take for example the following use case &#8211; the standard [...]]]></description>
			<content:encoded><![CDATA[<p>With the arrival of Zend Framework version 1.8 came the application resource plugins. These nifty little classes help bootstrap your application&#8217;s resources (views, layouts, database connections, etc). The default behaviour is suitable for most needs however, occasionally, you&#8217;re going to want to perform some extra functionality.</p>
<p>Take for example the following use case &#8211; the standard DB resource plugin instantiates a database connection based on supplied parameters and registers it with <code>Zend_Db_Table_Abstract::setDefaultAdapter()</code>. What if you want to register the connection in the <code>Zend_Registry</code> as well? You could create a bootstrap method (<code>_initRegistry()</code> for example) and pull the adapter out of <code>Zend_Db_Table_Abstract</code> <em>or</em> you could simply extend the resource plugin.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// library/My/Application/Resource/Db.php</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">class</span> My_Application_Resource_Db <span style="color: #000000; font-weight: bold;">extends</span> Zend_Application_Resource_Db
<span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> init<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">null</span> <span style="color: #339933;">!==</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$db</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getDbAdapter</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            Zend_Registry<span style="color: #339933;">::</span><span style="color: #004000;">set</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'dbAdapter'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$db</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #b1b100;">return</span> parent<span style="color: #339933;">::</span><span style="color: #004000;">init</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>This class simply adds the created database adapter to the registry before continuing on with the default behaviour.</p>
<p>To let the application know about your custom plugin, you simply add the plugin path to your <code>application.ini</code> file, eg</p>

<div class="wp_syntax"><div class="code"><pre class="ini" style="font-family:monospace;">includePaths.library <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;"> APPLICATION_PATH </span><span style="color: #933;">&quot;/../library&quot;</span>
pluginPaths.My_Application_Resource <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;My/Application/Resource&quot;</span></pre></div></div>

<p>More reading is available here &#8211; <a href="http://framework.zend.com/manual/en/zend.application.theory-of-operation.html">http://framework.zend.com/manual/en/zend.application.theory-of-operation.html</a></p>
<p>Further examples here &#8211; <a href="http://framework.zend.com/manual/en/zend.application.examples.html">http://framework.zend.com/manual/en/zend.application.examples.html</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.philipbrown.id.au/2009/06/extending-zend-framework-application-resource-plugins/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->