In today&rsquo;s post, we look at one of the simplest and most effective components of the Zend Framework that allows us to create extendable and extensible Zend Framework applications - Zend Application Resource Plugins (combined with the Strategy Pattern). If you want to ensure your apps can grow without heartache, read on.
Zend Framework Bootstrap Articles
The Zend Framework Bootstrap can be one of the key aspects of getting up and running quickly with the Zend Framework. Let&rsquo;s make it easy.
<p>Ok, we&rsquo;ve established that with the Zend Framework, we need to do a bit more work than some of the other frameworks to get up to speed - but that&rsquo;s not necessarily a bad thing - right?! But it can be a bit tedious and it&rsquo;s something as professional developers, we want to automate away. So we&rsquo;ve been addressing in this series how to do just that with a custom, extendable bootstrap class.</p> <p>In the <a href="http://www.maltblue.com/2011/10/software-development/php/a-simple-bootstrap-for-the-zend-framework" title="A Simple Zend Framework Bootstrap">first part of the series</a> we laid the foundation of our custom bootstrap class by creating a custom class directory structure, adding its namespace to the application ini and modifying the default application bootstrap so that it extends from it and had a look at the first component - caching.</p> <p>Then, in <a href="http://www.maltblue.com/2011/11/software-development/php/frameworks/zend-framework/zend-framework-bootstrap-made-simple-part-two" title="The Zend Framework Bootstrap made simple (Part 2)">the second part of the series</a>, we built on the foundation laid in part one by creating plugin resources for the <em>routing table</em>, <em>application navigation</em> and the <em>database connections</em> - these being some of the most common tasks, usually, associated with a web-based application.</p> <p>In this, the third and final part of the series, I&rsquo;m going to finish up by looking at application placeholders and surprise, no not logging as originally promised, but <em>pagination</em>. As an added extra, we&rsquo;re going to be using a <em>key feature</em> of Zend Application to make it a breeze.</p>
<p>In the <a href="http://www.maltblue.com/2011/10/software-development/php/a-simple-bootstrap-for-the-zend-framework" title="A Simple Zend Framework Bootstrap">first part of the series</a>, you&rsquo;ll remember that we laid the foundation of our custom bootstrap class by creating a custom class directory structure, adding its namespace to the application ini and creating our custom bootstrap file that our application bootstrap will extend from.</p> <p>After we did that, we put in the first but arguably the most important plugin resource – caching and stored it in the application registry. In this post we&rsquo;re going to be building on that work and adding in three new plugin resources: routing, navigation and databases.</p>
<p>When you&rsquo;re creating a new project with the Zend Framework, unlike other frameworks, you need to do more legwork. This isn&rsquo;t necessarily a bad thing, but it can sure slow you down when you&rsquo;re trying to plough through a project.</p> <p>I really enjoy using it, as it has a very well structured approach – and I like structure – it clearly lays out a file-system structure for <em>modules</em>, <em>controllers</em>, <em>actions</em>, <em>forms</em>, <em>models</em> and so on. It has good, but basic, tooling, allowing for modest project initialisation. But despite all this, it still requires a healthy investment on our part to get a proper foundation in place to use it productively.</p> <p>In a recent project I encountered this situation and felt that I mustn&rsquo;t be the only one to do so. As I plan to keep using Zend Framework I want to work around this situation and get as much productivity out of it as possible right from the get go. But how to do this?</p> <h2 id="bootstrapping">Bootstrapping</h2> <p>Well the primary focus for me is bootstrapping. It provides the majority of the core services that every project needs, from routing, data source connections, authentication, authorisation, navigation, caching and so on. So it stands to reason that it&rsquo;s a good place to start. So I want to cover what should go in to a good working bootstrap.</p>