<?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>Ingredients » Nick's Notepad &#187; Zend Framework</title>
	<atom:link href="http://www.ingredients.com.au/nick/category/code/zend-framework/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.ingredients.com.au/nick</link>
	<description>Nick's Notepad</description>
	<lastBuildDate>Fri, 18 Dec 2009 06:05:44 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>A note about the Zend Framework in Action cover</title>
		<link>http://www.ingredients.com.au/nick/2008/07/02/a-note-about-the-zend-framework-in-action-cover/</link>
		<comments>http://www.ingredients.com.au/nick/2008/07/02/a-note-about-the-zend-framework-in-action-cover/#comments</comments>
		<pubDate>Wed, 02 Jul 2008 01:42:59 +0000</pubDate>
		<dc:creator>Nick</dc:creator>
				<category><![CDATA[Zend Framework]]></category>

		<guid isPermaLink="false">http://www.ingredients.com.au/nick/2008/07/02/a-note-about-the-zend-framework-in-action-cover/</guid>
		<description><![CDATA[While chatting to a friend and mentioning that my work on the book included diagrams, he somehow thought that included the cover. So just for clarification; I had no part in the cover other than choosing from a selection of three. That said, I do quite like the characters on the Manning books even if [...]]]></description>
			<content:encoded><![CDATA[<p>While chatting to a friend and mentioning that my work on <a href="http://www.manning.com/allen/" title="Zend Framework in Action">the book</a> included diagrams, he somehow thought that included the cover. So just for clarification; I had no part in the cover other than choosing from a selection of three.</p>

<p>That said, I do quite like the characters on the Manning books even if the accompanying font choice seems a little dated. I imagine that having to choose book covers for tech books must be a painful experience if you don&#8217;t have something like the O&#8217;Reilly single-tone prints or these Manning characters. This <a href="http://www.manning-sandbox.com/thread.jspa?threadID=8561" title="Reader thoughts on Manning covers: what's your opinion? post on Manning forum">old post on Manning&#8217;s forum</a> really made me laugh though:</p>

<blockquote>&#8220;As a frequent purchaser of computer books however, I feel that I would be remiss if I did not tell you how thoroughly the cover of the book sucks. It&#8217;s major league weirdo shit &#8211; and I mean that in the most constructively critical way possible.</blockquote>

<p>Luckily, he wasn&#8217;t specifically talking about our cover which could be seen as representing the grace that Zend Framework brings to PHP, that, or it was the best one of the three they showed us. I do like the brown though!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ingredients.com.au/nick/2008/07/02/a-note-about-the-zend-framework-in-action-cover/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Officially a lazy bugger blogger</title>
		<link>http://www.ingredients.com.au/nick/2008/06/23/officially-a-lazy-blogger/</link>
		<comments>http://www.ingredients.com.au/nick/2008/06/23/officially-a-lazy-blogger/#comments</comments>
		<pubDate>Mon, 23 Jun 2008 05:53:54 +0000</pubDate>
		<dc:creator>Nick</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Zend Framework]]></category>

		<guid isPermaLink="false">http://www.ingredients.com.au/nick/2008/06/23/officially-a-lazy-blogger/</guid>
		<description><![CDATA[Inspired by The Local&#8217;s accusations of abandonment, I realised I&#8217;d not mentioned one of my new hangouts. I&#8217;ve been trying to compete with Rob Allen on the blog for our almost-in-production book Zend Framework in Action. As always he&#8217;s way ahead of me just as he is on the Author&#8217;s forum! So if you&#8217;re really [...]]]></description>
			<content:encoded><![CDATA[<p>Inspired by <a href="http://blogs.com.au/thelocal/2008/06/02/dont-abandon-your-business-blog/" title="Don't abandon your business blog post at The Local">The Local&#8217;s</a> accusations of abandonment, I realised I&#8217;d not mentioned one of my new hangouts. I&#8217;ve been trying to compete with <a href="http://www.akrabat.com" title="Rob Allen's blog">Rob Allen</a> on <a href="http://www.zendframeworkinaction.com/" title="Zend Framework in Action blog">the blog</a> for our almost-in-production book <a href="http://www.manning.com/allen/" title="Zend Framework in Action">Zend Framework in Action</a>. As always he&#8217;s way ahead of me just as he is on the <a href="http://www.manning-sandbox.com/forum.jspa?forumID=329" title="Author's forum for Zend Framework in Action">Author&#8217;s forum</a>!</p>

<p>So if you&#8217;re really missing what I have to say or need to tell me what you have to say, you can catch me in any of those places. Once the book comes out I&#8217;m sure I&#8217;ll have more time for this blog.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ingredients.com.au/nick/2008/06/23/officially-a-lazy-blogger/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>My thoughts on his thoughts on PHP</title>
		<link>http://www.ingredients.com.au/nick/2008/06/16/my-thoughts-on-his-thoughts-on-php/</link>
		<comments>http://www.ingredients.com.au/nick/2008/06/16/my-thoughts-on-his-thoughts-on-php/#comments</comments>
		<pubDate>Mon, 16 Jun 2008 11:52:44 +0000</pubDate>
		<dc:creator>Nick</dc:creator>
				<category><![CDATA[Zend Framework]]></category>

		<guid isPermaLink="false">http://www.ingredients.com.au/nick/2008/06/16/my-thoughts-on-his-thoughts-on-php/</guid>
		<description><![CDATA[On the Zend Framework mailing list JurriÃ«n Stutterheim asked for thoughts on his blog post PHP&#8230; what to say?. I started replying to the list but found I&#8217;d written so much that it was better to clutter up my own space than a public one. &#8220;Zend Framework already has a set of conventions. In my [...]]]></description>
			<content:encoded><![CDATA[<p>On the Zend Framework mailing list JurriÃ«n Stutterheim asked for thoughts on his blog post <a href="http://www.norm2782.com/includes/trackback.php?id=5" title="PHP... what to say? blog post">PHP&#8230; what to say?</a>. I started replying to the list but found I&#8217;d written so much that it was better to clutter up my own space than a public one.</p>

<blockquote>&#8220;Zend Framework already has a set of conventions. In my opinion it&#8217;s a good thing to improve these conventions even further and make them apply not only for Zend Framework, but for PHP as a whole.&#8221;</blockquote>

<p>I suspect that Zend Framework will introduce an interesting dilemma for Zend and PHP where by improving more users experience and understanding of so called advanced programming concepts like OOP, design patterns, etc, they will also increase their expectations of the underlying language.</p>

<p>What onus that puts on the development of PHP itself is really the question. It may be a positive one, with PHP developers and those from other frameworks/languages able to move between their framework and Zend Framework more comfortably. The negative may be that Zend Framework is working on a layer above PHP to the extent that it begins to feel like a language within a language (something that Lukas Smith has been referring to in his <a href="http://pooteeweet.org/blog/1151" title="Kiss my ...">Kiss my &#8230;</a> post) and the nagging question then creeps in as to how much we are duplicating the functionality of a web development focussed language in a web development focussed framework? I&#8217;ve already started kicking myself for getting a bit carried away and unnecessarily using Zend Framework components when the same can be achieved with PHP.</p>

<p>An even bigger question that I&#8217;m dealing with right now is what to train new programmers in? The argument is almost endless, but the answer is rarely PHP for any other reason than ease of entry. If developers are going to be working at the higher level that Zend Framework has moved development to, then the question is why start new programmers with a programming language that is rarely recommended as being at that level?</p>

<p>Zend Framework is actually a good way to get someone into PHP and also make sure they keep away from so many of the bad habits that have plagued PHP development. But that is partly a case of keeping them away from PHP itself. Wouldn&#8217;t they then be better learning a language that is often used to teach programming, like Python, and once they&#8217;ve developed good habits introduce them to a framework for development? In other words I would prefer to have someone learn PHP via Zend Framework whereas with Python I&#8217;d be content to have someone learn Python and then a framework.</p>

<p>The question I know that only time will answer is what the cross-pollination will be between Zend Framework and PHP. Targetting that at the core developers I&#8217;m interested to know what future plans there are for removing and/or adapting Zend Framework features that become native to PHP itself and/or become more widely hosted such as 5.3&#8242;s namespaces against Zend Framework&#8217;s pseudo-namespaces.</p>

<p>Of course I&#8217;m not naive enough to think that Zend hasn&#8217;t thought about any of this, but then I&#8217;m not looking at it from that high up. From my perspective the disciplines that Zend Framework introduce actually open possibilities that are as lateral as they are upwardly PHP. Once you climb the Zend Framework mountain you begin to see it has neighbouring mountains that it has a lot in common with and that&#8217;s actually a good thing.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ingredients.com.au/nick/2008/06/16/my-thoughts-on-his-thoughts-on-php/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Zend Framework in Action in the Works</title>
		<link>http://www.ingredients.com.au/nick/2007/09/17/zend-framework-in-action-in-the-works/</link>
		<comments>http://www.ingredients.com.au/nick/2007/09/17/zend-framework-in-action-in-the-works/#comments</comments>
		<pubDate>Mon, 17 Sep 2007 01:25:08 +0000</pubDate>
		<dc:creator>Nick</dc:creator>
				<category><![CDATA[Zend Framework]]></category>

		<guid isPermaLink="false">http://www.ingredients.com.au/nick/2007/09/17/zend-framework-in-action-in-the-works/</guid>
		<description><![CDATA[Since Rob has beaten me to the punch, the only thing left for me to do is put up a pretty picture of the cover so you can see what has occupied the time I may or may not have put into this blog! The story is that the book that we are co-authoring on [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.manning.com/allen/" title="Zend Framework in Action early access page"><img id="image58" src="http://www.ingredients.com.au/nick/content/zfia_cover.gif" alt="Zend Framework in Action cover" class="alignleft" /></a> Since <a href="http://akrabat.com/2007/09/13/zend-framework-book-coming-soon/" title="Book announcement on Rob Allen's blog">Rob</a> has beaten me to the punch, the only thing left for me to do is put up a pretty picture of the cover so you can see what has occupied the time I may or may not have put into this blog!</p>

<p>The story is that <a href="http://www.manning.com/allen/" title="Zend Framework in Action early access page">the book</a> that we are co-authoring on the <a href="http://framework.zend.com" title="Zend Framework">Zend Framework</a> has now been released through Manning&#8217;s early access program. This means you can read it as we&#8217;re writing it, basically.</p>

<p>It&#8217;s certainly hard work, in particular trying to find the time alongside the &#8220;day job&#8221;, but nonetheless rewarding and I do have to say thanks to Rob for asking me to be part of the process. When he originally asked I was quite taken aback in a &#8220;why me?!&#8221; way.</p>

<p>Anyway, I&#8217;ll chat more about it now that it&#8217;s more official and if you&#8217;re interested please feel free to let us know any thoughts/comments/ideas through either of our blogs or the <a href="http://www.manning-sandbox.com/forum.jspa?forumID=329" title="Zend Framework in Action author's forum">author&#8217;s forum</a>. The point of this early access program is to get as much feedback as possible and therefore improve the quality of the final publication.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ingredients.com.au/nick/2007/09/17/zend-framework-in-action-in-the-works/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Zend Framework article on Zend Developer Zone</title>
		<link>http://www.ingredients.com.au/nick/2007/07/25/zend-framework-article-on-zend-developer-zone/</link>
		<comments>http://www.ingredients.com.au/nick/2007/07/25/zend-framework-article-on-zend-developer-zone/#comments</comments>
		<pubDate>Wed, 25 Jul 2007 02:11:27 +0000</pubDate>
		<dc:creator>Nick</dc:creator>
				<category><![CDATA[Zend Framework]]></category>

		<guid isPermaLink="false">http://www.ingredients.com.au/nick/2007/07/25/zend-framework-article-on-zend-developer-zone/</guid>
		<description><![CDATA[I know my blog is watched mainly for its Zend Framework content so I should mention that I have an article up on Zend Developer Zone entitled Zend Framework and the New Hybrid Designer. It will likely be preaching to the converted for many of you but having had the odd &#8220;why use Zend Framework&#8221; [...]]]></description>
			<content:encoded><![CDATA[<p>I know my blog is watched mainly for its Zend Framework content so I should mention that I have an article up on Zend Developer Zone entitled <a href="http://devzone.zend.com/article/2350-Zend-Framework-and-the-New-Hybrid-Designer">Zend Framework and the New Hybrid Designer</a>.</p>

<p>It will likely be preaching to the converted for many of you but having had the odd &#8220;why use Zend Framework&#8221; discussion I felt it would be good to write it down in some form. Feel free to brutalise it as you see fit!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ingredients.com.au/nick/2007/07/25/zend-framework-article-on-zend-developer-zone/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Zend_Acl and Zend_Auth Example</title>
		<link>http://www.ingredients.com.au/nick/2007/02/08/zend_acl-and-zend_auth-example/</link>
		<comments>http://www.ingredients.com.au/nick/2007/02/08/zend_acl-and-zend_auth-example/#comments</comments>
		<pubDate>Thu, 08 Feb 2007 04:12:19 +0000</pubDate>
		<dc:creator>Nick</dc:creator>
				<category><![CDATA[Zend Framework]]></category>

		<guid isPermaLink="false">http://www.ingredients.com.au/nick/2007/02/08/zend_acl-and-zend_auth-example/</guid>
		<description><![CDATA[Simon Mundy has written up a well-worth-reading Zend_Acl / Zend_Auth example scenario in which he illustrates setting up authorisation and access privileges with the Zend Framework.]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.peptolab.com/" title="Peptolab">Simon Mundy</a> has written up a well-worth-reading <a href="http://www.nabble.com/Zend_Acl---Zend_Auth-example-scenario-tf3165728s16154.html">Zend_Acl / Zend_Auth example scenario</a> in which he illustrates setting up authorisation and access privileges with the Zend Framework.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ingredients.com.au/nick/2007/02/08/zend_acl-and-zend_auth-example/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rob Allen&#8217;s Zend Framework Tutorial</title>
		<link>http://www.ingredients.com.au/nick/2006/08/18/rob-allens-zend-framework-tutorial/</link>
		<comments>http://www.ingredients.com.au/nick/2006/08/18/rob-allens-zend-framework-tutorial/#comments</comments>
		<pubDate>Fri, 18 Aug 2006 00:04:43 +0000</pubDate>
		<dc:creator>Nick</dc:creator>
				<category><![CDATA[Zend Framework]]></category>

		<guid isPermaLink="false">http://www.ingredients.com.au/nick/2006/08/18/rob-allens-zend-framework-tutorial/</guid>
		<description><![CDATA[Anyone looking for a good comprehensive run through of a Zend Framework application should read Rob Allen&#8217;s My Take on a Zend Framework Tutorial. As it&#8217;s a PDF, you might like to read it using this trick from Jon Udell: Vertical PowerBook as ebook reader. He uses a Mac but I&#8217;m sure you can achieve [...]]]></description>
			<content:encoded><![CDATA[<p>Anyone looking for a good comprehensive run through of a Zend Framework application should read Rob Allen&#8217;s <a href="http://www.akrabat.com/2006/08/16/my-take-on-a-zend-framework-tutorial/trackback/">My Take on a Zend Framework Tutorial</a>.</p>

<p>As it&#8217;s a PDF, you might like to read it using this trick from Jon Udell: <a href="http://weblog.infoworld.com/udell/2006/08/02.html">Vertical PowerBook as ebook reader</a>. He uses a Mac but I&#8217;m sure you can achieve much the same on other OS&#8217;s.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ingredients.com.au/nick/2006/08/18/rob-allens-zend-framework-tutorial/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>RewriteRouter and Zend_Config play together</title>
		<link>http://www.ingredients.com.au/nick/2006/07/18/rewriterouter-and-zend_config-play-together/</link>
		<comments>http://www.ingredients.com.au/nick/2006/07/18/rewriterouter-and-zend_config-play-together/#comments</comments>
		<pubDate>Mon, 17 Jul 2006 15:30:57 +0000</pubDate>
		<dc:creator>Nick</dc:creator>
				<category><![CDATA[Zend Framework]]></category>

		<guid isPermaLink="false">http://www.ingredients.com.au/nick/2006/07/18/rewriterouter-and-zend_config-play-together/</guid>
		<description><![CDATA[While getting the hang of the Zend_Controller_RewriteRouter, which is now included in Zend Framework 0.1.5, I was adding the routes in my index.php (bootstrap) file and wondered if there was any way of storing them elsewhere. It is possible to loop over Zend_Controller_RewriteRouter::addRoutes() but the method I will describe here is based on some recent [...]]]></description>
			<content:encoded><![CDATA[<p>While getting the hang of the <a href="http://framework.zend.com/manual/en/zend.controller.rewriterouter.html">Zend_Controller_RewriteRouter</a>, which is now included in <a href="http://framework.zend.com/">Zend Framework 0.1.5</a>, I was adding the routes in my index.php (bootstrap) file and wondered if there was any way of storing them elsewhere. It is possible to loop over Zend_Controller_RewriteRouter::addRoutes() but the method I will describe here is based on some recent updates to Zend_Controller_RewriteRouter by its author <a href="http://www.linkedin.com/in/martel">Michael Minicki</a>.</p>

<p>The point of RewriteRouter is to map urls, like ingredients.com.au/recipe/tomato_sambal, to whatever controller, action and parameters needed without having to use external (and often painful!) methods like mod_rewrite.</p>

<p>For the sake of this article I&#8217;ll use a relatively simple URL&#8230;</p>

<pre><code>ingredients.com.au/articles/cooking/
</code></pre>

<p>First setup some routes in a config file &#8220;routes.php&#8221;. Note that this does require the latest version of the RewriteRouter which needs to be checked out from the <a href="http://framework.zend.com/wiki/display/ZFDEV/Zend+Framework+Subversion+Standards">subversion repository</a>&#8230;</p>

<pre><code>$config['routes']['articles'] = 
new Zend_Controller_Router_Route('articles/:category', 
array('category' =&gt; 'all', 
       'controller' =&gt; 'articles', 
       'action'      =&gt; 'index' ), 
       array('category' =&gt; '[a-z_]+') );
</code></pre>

<p>This establishes a route called &#8220;articles&#8221; that will respond to any url of the form &#8220;/articles/whatever&#8221; with the colon in :category indicating that it is an url variable that can be recovered through Zend_Controller_Action::_getParam( &#8216;category&#8217; ). The controller and action indexes make the action &#8220;indexAction&#8221; in the controller file &#8220;ArticlesController.php&#8221; the final target. To cover cases where there is no category specified the default setting &#8220;all&#8221; is given. For extra assurance :category has to be a string containing only lower case letters and underscores as indicated by the final requirements array.</p>

<p>Next load them into the bootstrap file using Zend_Config_Array:</p>

<pre><code>$routes = new Zend_Config( 
        Zend_Config_Array::load( 
       '../application/configuration/routes.php', 'routes' ) );
</code></pre>

<p>Then create the RewriteRouter object and pass it the $routes&#8230;</p>

<pre><code>$router = new Zend_Controller_RewriteRouter;
$router-&gt;addRoutes( $routes );
</code></pre>

<p>All that is needed now is to pass the $router to the front controller&#8230;</p>

<pre><code>$controller = Zend_Controller_Front::getInstance();
$controller-&gt;setRouter( $router );
</code></pre>

<p>That&#8217;s it, now the routes are nicely stored outside of the bootstrap file and with the rest of the domain files.</p>

<h3>Further Reading</h3>

<p>Aside from the manual pages mentioned I can&#8217;t close without pointing to an actual recipe for <a href="http://www.ingredients.com.au/sandra/2006/05/17/tomato-sambal/">tomato sambal</a> !!</p>

<h3>Endnote</h3>

<p>I should also mention that it&#8217;s well worth getting involved with the development of the framework even if you can only do so in a small way. After a relatively short discussion via the <a href="http://framework.zend.com/issues/browse/ZF-244">issue tracker</a> about having some means to load routes in one hit, Michael Minicki had implemented one (thanks Michael).</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ingredients.com.au/nick/2006/07/18/rewriterouter-and-zend_config-play-together/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Zend Frameworking underwater.com.au</title>
		<link>http://www.ingredients.com.au/nick/2006/07/04/zend-frameworking-underwater-com-au/</link>
		<comments>http://www.ingredients.com.au/nick/2006/07/04/zend-frameworking-underwater-com-au/#comments</comments>
		<pubDate>Tue, 04 Jul 2006 12:12:26 +0000</pubDate>
		<dc:creator>Nick</dc:creator>
				<category><![CDATA[Zend Framework]]></category>

		<guid isPermaLink="false">http://www.ingredients.com.au/nick/2006/07/04/zend-frameworking-underwatercomau/</guid>
		<description><![CDATA[Now that the host for underwater.com.au has upgraded to PHP5 I&#8217;m working on migrating it to use the Zend Framework. I thought it may be interesting to run through a few of the reasons I&#8217;ve chosen to do so especially while the framework is in such an early stage of development. &#8220;Underware&#8221; The engine, code-named [...]]]></description>
			<content:encoded><![CDATA[<p>Now that the host for <a href="http://www.underwater.com.au" title="underwater.com.au">underwater.com.au</a> has upgraded to PHP5 I&#8217;m working on migrating it to use the <a href="http://framework.zend.com" title="Zend Framework">Zend Framework</a>. I thought it may be interesting to run through a few of the reasons I&#8217;ve chosen to do so especially while the framework is in such an early stage of development.</p>

<h3>&#8220;Underware&#8221;</h3>

<p>The engine, code-named &#8220;Underware&#8221;, that <a href="http://www.underwater.com.au" title="underwater.com.au">underwater.com.au</a> currently runs on is built almost entirely (excluding a few additional class files) from my own code. Developed, via several projects, over the course of about five years from a modified version of the PHP e-Commerce application <a href="http://share.whichever.com/index.php?SCREEN=freetrade" title="FreeTrade ecommerce toolkit">Freetrade</a> and the <a href="http://www.zend.com/zend/art/free-energy.php" title="Zend article on the concept behind Freetrade">FreeEnergy</a> structure (Actually, it&#8217;s interesting to look back over that FreeEnergy article to see how it&#8217;s almost a <a href="http://en.wikipedia.org/wiki/Model_view_controller" title="Model-view-controller entry in Wikipedia">Model-View-Controller</a> structure), Underware is now more object-oriented, more MVC&#8217;ed and more woven with <a href="http://en.wikipedia.org/wiki/Design_pattern_%28computer_science%29" title="Design_pattern entry in Wikipedia">design patterns</a> than its early incarnations, however it still has loose threads.</p>

<h3>Why grow your own?</h3>

<p>Considering the amount of freely-available, open-source, PHP code it seems idiotic to be doing it all yourself. Sadly, the number of applications available is no indication of their quality, nor whether they will play nicely together, a point taken up by Clay Loveless in his <a href="http://killersoft.com/randomstrings/2006/06/14/stop-writing-loner-applications/">Stop Writing Loner Applications</a> post.</p>

<p>At every stage of Underware&#8217;s development I looked at pre-existing solutions, hoping to find one that wouldn&#8217;t force me to duplicate components I already had, such as user management. It wasn&#8217;t necessarily that I had better code, more that what I did have was only what I needed. Besides, I knew as I worked on it the code quality would also improve. Inevitably, after spending many unbillable hours pouring through different solutions I&#8217;d look at the clock and think &#8220;I could have spent those hours moving forward and coding a solution&#8221;!</p>

<h4>Pros of doing it all yourself</h4>

<ul>
<li>You only build, debug and support what you need.</li>
<li>You know all the code.</li>
<li>You learn a lot.</li>
</ul>

<h4>Cons of doing it all yourself</h4>

<ul>
<li>You have to build and support every bit of code and unless you build it it&#8217;s not just going to appear from somewhere.</li>
<li>You have to document it all.</li>
<li>You have to spend time researching solutions to every issue, including system level ones that are not directly providing solutions for your clients.</li>
</ul>

<p>Thankfully the increasing amount of frameworks available (i.e. rather than finished applications) combined with the growing object-oriented&#8217;ness of PHP mean it&#8217;s less of an either or situation.</p>

<h3>So why Zend Framework?</h3>

<p>Honestly, I think because it feels right and I say that not to be facetious, but partly because I see so many lengthy arguments for and against such and such framework as if one or the other holds the golden key. Part of the reason I went back to my roots was to show the influences on my way of structuring web applications and if you&#8217;re interested enough to look into them you may see some similarities. For me the Zend Framework not only fits the way I&#8217;m currently working but moves it forward, tying up some of the aforementioned loose threads for example.</p>

<p>More pragmatically there are factors like the fact that my clients can worry less about being so totally dependant on me for every facet of their applications; I can benefit from all the external input to the framework itself; I can focus on solving client needs more and system level needs less and not to be ignored is the <a href="http://www.zend.com" title="Zend is the PHP company">Zend</a> part of the framework which for me puts at least some stamp of longevity and consistency on the code base.</p>

<h3>Some further Underware influences</h3>

<ul>
<li><p>Philip Greenspun&#8217;s <a href="http://philip.greenspun.com/seia/" title="Software Engineering for Internet Applications textbook">Software Engineering for Internet Applications</a>, in particular the section on <a href="http://philip.greenspun.com/seia/content-management">content management</a>.</p></li>
<li><p>Design patterns picked up from various sources, but really understood in <a href="http://www.headfirstlabs.com/books/hfdp/index.php">Head First Design Patterns</a> and <a href="http://www.phppatterns.com">phpPatterns</a>. The Head First Java is also a good read, particularly if like me you&#8217;re really only after a better understanding of OOP rather than wanting to specifically program Java applications.</p></li>
<li><p><a href="http://www.lastcraft.com/">Marcus Baker&#8217;s</a> articles on unit testing. I plan to read more about <a href="http://www.phpunit.de/">PHPUnit</a> too but Marcus&#8217; writing was really a good intro to a practice I must practice more of!</p></li>
</ul>

<h3>Some current Zend Framework reading</h3>

<ul>
<li><a href="http://polarblogs.com/luke/archives/16">Using Layouts with the Zend Framework</a></li>
<li><a href="http://hades.phparch.com/ceres/public/article/index.php/art::zend_framework::tutorial">Zend Framework Tutorial</a></li>
<li><a href="http://devzone.zend.com/node/view/id/119">Blueprint for PHP Applications</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.ingredients.com.au/nick/2006/07/04/zend-frameworking-underwater-com-au/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Custom View Helpers in Zend Framework</title>
		<link>http://www.ingredients.com.au/nick/2006/06/26/custom-view-helpers-in-zend-framework/</link>
		<comments>http://www.ingredients.com.au/nick/2006/06/26/custom-view-helpers-in-zend-framework/#comments</comments>
		<pubDate>Mon, 26 Jun 2006 11:18:25 +0000</pubDate>
		<dc:creator>Nick</dc:creator>
				<category><![CDATA[Zend Framework]]></category>

		<guid isPermaLink="false">http://www.ingredients.com.au/nick/2006/06/26/custom-view-helpers-in-zend-framework/</guid>
		<description><![CDATA[The Zend Framework Manual describes View Helpers like so: &#8220;In your view scripts, often it is necessary to perform certain complex functions over and over; e.g., formatting a date, generating form elements, or displaying action links. You can use helper classes to perform these behaviors for you.&#8221; Currently the framework (version 0.1.3) includes a small [...]]]></description>
			<content:encoded><![CDATA[<p>The <a href="http://framework.zend.com/manual/" title="Manual for the Zend Framework">Zend Framework Manual</a> describes View Helpers like so:</p>

<blockquote>
  <p>&#8220;In your view scripts, often it is necessary to perform certain complex functions over and over; e.g., formatting a date, generating form elements, or displaying action links. You can use helper classes to perform these behaviors for you.&#8221;</p>
</blockquote>

<p>Currently the framework (version 0.1.3) includes a small selection of form helpers which will no doubt expand as it matures. For now I&#8217;m more interested in the ability to add custom helpers for specific project use. The first thing I did was to set up the same directory structure as Zend_View_Helper as is suggested when <a href="http://framework.zend.com/manual/en/zend.controller.subclassing.html" title="Manual entry on subclassing controllers">subclassing controllers</a>:</p>

<pre><code>library/
    Zend/
        View/
            Helper/
    MyProject/
        View/
            Helper/
</code></pre>

<p>Having my project specific helper files in library/MyProject/View/Helper/ will make it easy to keep them separate from Zend core updates.</p>

<p>The next step is to tell Zend_View to look in the custom helper directory as well as the default Zend helper directory. This just requires adding the new helper path to the Zend_View object I created in the public_html/index.php file:</p>

<pre><code>$view = new Zend_View;
$view-&gt;addHelperPath('MyProject/View/Helper');
</code></pre>

<h3>Cautionary Note <em>(* see update below)</em></h3>

<p>The above is actually a bit of a fiddle to get working if you decide like I did to use a relative path to your helper files. I had set&#8230;</p>

<pre><code>set_include_path( /home/exciting_zfw_site/library/ );
</code></pre>

<p>&#8230;pointing to the main Zend library directory, however, Zend_View_Abstract:: _loadClass() uses is_readable() as a check before loading any helper or filter files like so&#8230;</p>

<pre><code>if (is_readable($dir . $file)) {
    include $dir . $file;

    if (! class_exists($class, false)) {
        $msg = "$type '$name' loaded 
                        but class '$class' not found within";
        throw new Zend_View_Exception($msg);
    }

    return $class;
}
</code></pre>

<p>&#8230;and since is_readable just ignores include paths, your new helper files won&#8217;t be found. This is currently <a href="http://framework.zend.com/issues/browse/ZF-101" title="Bug listing in Zend Framework bug tracker">listed as a bug</a> but for the moment I simply changed&#8230;</p>

<pre><code>if (is_readable($dir . $file)) {
    include $dir . $file;
</code></pre>

<p>&#8230;to&#8230;</p>

<pre><code>if (include $dir . $file) {
</code></pre>

<p>&#8230;and it worked fine. Portability was the reason I wanted to keep the paths relative as I move files from a development server to the live server. It&#8217;s much easier to keep as few path configuration settings as possible.</p>

<p>The next step is pretty well documented in the manual but for the sake of completeness I&#8217;ll keep going. Create a new helper file:</p>

<pre><code>class Zend_View_Helper_DoStuff {

    public function doStuff()
    {
        return 'Hello to you all';
    }
}
</code></pre>

<h3>Another Cautionary Note</h3>

<p>Something that caught me out was that the new helper class must be called Zend_View_Helper_YourNameHere rather than MyProject_View_Helper_YourNameHere which seems a little odd considering it&#8217;s position in the directory structure I mentioned before. While logically it is a Zend_View helper class, it will be kept with other subclassed files with your own &#8220;namespaced&#8221; class names under the MyProject directory so it seems to break a convention.</p>

<h3>Ready to use</h3>

<p>After saving the new helper file in MyProject/View/Helper/DoStuff.php it should be available to use in your view scripts like so:</p>

<pre><code>&lt;?php echo $this-&gt;doStuff(); ?&gt;
</code></pre>

<p>When writing helper classes the key points to initially getting them to work are the naming conventions as illustrated by my doStuff example:</p>

<ol>
<li>Class name must be Zend_View_Helper_DoStuff</li>
<li>The class must contain a public function doStuff()</li>
<li>The file must be save as DoStuff.php</li>
</ol>

<p>As mentioned in my post on <a href="2006/06/10/getting-to-know-zend_view/">getting to know Zend_View</a> elements of the above may well change as development continues.</p>

<h3>Further Reading</h3>

<p><a href="http://framework.zend.com/manual/en/zend.view.helpers.html">View Helpers in the Zend Framework Manual</a></p>

<h3>* Update</h3>

<p>Forget the above hack&#8230;</p>

<pre><code>if (include $dir . $file) {
</code></pre>

<p>&#8230;as it will produce warnings as Zend_View_Abstract::_LoadClass() attempts to include the doStuff file from any other path in the _path stack. Instead the only solution I&#8217;ve found to currently work is to specify a relative path like so:</p>

<pre><code>$view-&gt;addHelperPath('../MyProject/UW/View/Helper');
</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://www.ingredients.com.au/nick/2006/06/26/custom-view-helpers-in-zend-framework/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
