<?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; resource plugins</title>
	<atom:link href="http://blog.philipbrown.id.au/tag/resource-plugins/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.philipbrown.id.au</link>
	<description></description>
	<lastBuildDate>Mon, 05 Dec 2011 22:22:44 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Where&#8217;s my Front Controller?</title>
		<link>http://blog.philipbrown.id.au/2011/10/wheres-my-front-controller/</link>
		<comments>http://blog.philipbrown.id.au/2011/10/wheres-my-front-controller/#comments</comments>
		<pubDate>Mon, 31 Oct 2011 04:43:05 +0000</pubDate>
		<dc:creator>Phil</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Zend Framework]]></category>
		<category><![CDATA[application resource plugin]]></category>
		<category><![CDATA[front controller]]></category>
		<category><![CDATA[resource plugins]]></category>

		<guid isPermaLink="false">http://blog.philipbrown.id.au/?p=176</guid>
		<description><![CDATA[I&#8217;ve been spending a bit of time on StackOverflow lately and have even earned myself a bronze &#8220;Zend Framework&#8221; badge. One thing I continually see in questions surrounding the bootstrap process and resource plugins is this&#8230; protected function _initSomething&#40;&#41; &#123; $front = FrontController::getInstance&#40;&#41;; &#160; // and so on This is not the right way to [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been spending a bit of time on StackOverflow lately and have even earned myself a bronze &#8220;Zend Framework&#8221; badge.</p>
<p>One thing I continually see in questions surrounding the bootstrap process and resource plugins is this&#8230;</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000000; font-weight: bold;">function</span> _initSomething<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$front</span> <span style="color: #339933;">=</span> FrontController<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: #666666; font-style: italic;">// and so on</span></pre></div></div>

<p>This is not the right way to fetch the Front Controller. For starters, at this stage it may not have been bootstrapped, meaning options supplied via configuration may not have been applied.</p>
<p>Following the <a href="http://framework.zend.com/manual/en/zend.application.theory-of-operation.html#zend.application.theory-of-operation.bootstrap.dependency-tracking">Zend Application &#8211; Theory of Operation &#8211; Dependency Tracking</a> documentation, this is the correct method&#8230;</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000000; font-weight: bold;">function</span> _initSomething<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;">bootstrap</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'FrontController'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$front</span> <span style="color: #339933;">=</span> this<span style="color: #339933;">-&gt;</span><span style="color: #004000;">getResource</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'FrontController'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// and so on</span></pre></div></div>

<p>The same logic applies to any required resource; Bootstrap it first then fetch it from the application container. Simple.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.philipbrown.id.au/2011/10/wheres-my-front-controller/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<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 [...]]]></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! -->
