<?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>Leaking Abstraction</title>
	<atom:link href="http://www.leakingabstraction.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.leakingabstraction.com</link>
	<description>Caffeine, code, and ctrl+z</description>
	<lastBuildDate>Fri, 28 May 2010 02:40:46 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Service layers explained simply</title>
		<link>http://www.leakingabstraction.com/misc/service-layers-explained-simply/</link>
		<comments>http://www.leakingabstraction.com/misc/service-layers-explained-simply/#comments</comments>
		<pubDate>Fri, 28 May 2010 02:40:46 +0000</pubDate>
		<dc:creator>Andy Baird</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://www.leakingabstraction.com/?p=178</guid>
		<description><![CDATA[Being new to MVC's is a bit confusing. There's a lot of acronyms to understand before you can really start jumping in and coding anything. This couldn't be any more true for ZF -- ZF not only gives you a framework full of buzzwords, it also leaves the interpretation of what each really means up [...]]]></description>
			<content:encoded><![CDATA[<p>Being new to MVC's is a bit confusing. There's a lot of acronyms to understand before you can really start jumping in and coding anything. This couldn't be any more true for ZF -- ZF not only gives you a framework full of buzzwords, it also leaves the interpretation of what each really means up to you.</p>
<p>As a disclaimer, I have to admit that I am no where near the genius of someone like <a href="http://weierophinney.net/matthew/" onclick="pageTracker._trackPageview('/outgoing/weierophinney.net/matthew/?referer=');">Matthew Weier O'Phinney</a>. If you are, you probably will get little to nothing out of this blog post. In that case, I recommend you <a href="http://weierophinney.net/matthew/" onclick="pageTracker._trackPageview('/outgoing/weierophinney.net/matthew/?referer=');">read this</a> slideshow on service layers, presented by the lead ZF developer and guru himself.</p>
<p>I read and re-read those slides many times -- but I'm the type of person who doesn't understand something until I've experienced it. I was running into a problem with my MVC apps where I was re-writing controller code for manipulating models quite often. Throw AJAX into the mix and suddenly I'm copying and pasting whole actions almost completely. Throw a public facing web service into the mix and I've tripled my code size. My my, not very pragmatic at all.</p>
<h2>Implementing the service layer</h2>
<p>So, what's a programmer to do? If you're following the paradigm that controllers are solely for accepting input and rendering output, which I do, then the problem you have -- that is, the code you're copy and pasting -- needs to be re-used instead of re-copied. This is where the service layer comes in for me. The service layer becomes a common API for all your controllers to use - whether through AJAX, Web service, or your plain old webpage controllers.</p>
<p>For example, I have a service I call Service_User. This service contains static methods for reading and writing user models. Example method skeletons look like this:</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">class</span> Service_User <span style="color: #009900;">&#123;</span><br />
<span style="color: #000000; font-weight: bold;">public</span> static <span style="color: #000000; font-weight: bold;">function</span> save<span style="color: #009900;">&#40;</span><span style="color: #000088;">$user_id</span><span style="color: #339933;">,</span><span style="color: #000088;">$data</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
<span style="color: #666666; font-style: italic;">// Neat things happen here that saves a user model</span><br />
<span style="color: #009900;">&#125;</span><br />
<span style="color: #000000; font-weight: bold;">public</span> static <span style="color: #000000; font-weight: bold;">function</span> fetchAll<span style="color: #009900;">&#40;</span><span style="color: #000088;">$params</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
<span style="color: #666666; font-style: italic;">// Neat things happen here that returns a collection of user models</span><br />
<span style="color: #009900;">&#125;</span><br />
<span style="color: #000000; font-weight: bold;">public</span> static <span style="color: #000000; font-weight: bold;">function</span> delete<span style="color: #009900;">&#40;</span><span style="color: #000088;">$user_id</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
<span style="color: #666666; font-style: italic;">// Neat things happen here that deletes a user from the database</span><br />
<span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span></div></div>
<p>Now, all I have to worry about in my controllers is transforming the incoming data to correspond to the parameters of my service layer. My admin module, ajax module, and normal member controllers now all touch the very same code.</p>
<h2>Why don't I just make my model methods more useful?</h2>
<p>This was my gut reaction as well. Indeed, this is what I ended up doing on a whole application. You'll run into a couple of problems:</p>
<ul>
<li>These type of methods generally deal with input and output, while the goal of the model is usually to represent something logically in your application.</li>
<li>You'll usually want methods that deal with collections of models, which doesn't organize well within a model.</li>
</ul>
<p>I hope this helps clear up some confusion on service layers (well, at least how I use them). Think of them as the API for your application -- if you were going to externalize the internals of your application, what functions would you make? The service layer is the glue in between your models and controllers.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.leakingabstraction.com/misc/service-layers-explained-simply/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Over-engineering syndrome and becoming results-oriented</title>
		<link>http://www.leakingabstraction.com/articles/over-engineering-syndrome-and-becoming-results-oriented/</link>
		<comments>http://www.leakingabstraction.com/articles/over-engineering-syndrome-and-becoming-results-oriented/#comments</comments>
		<pubDate>Mon, 01 Mar 2010 20:27:35 +0000</pubDate>
		<dc:creator>Andy Baird</dc:creator>
				<category><![CDATA[Articles]]></category>

		<guid isPermaLink="false">http://www.leakingabstraction.com/?p=170</guid>
		<description><![CDATA[In January, I reflected on year 2009 as it pertained to my programming career. What had I accomplished?
I thought long and hard about this. I didn't publish any kick-ass new websites. I didn't make any major contributions to an open source project. The crowning achievement of my year was a Facebook app that accidentally exploded [...]]]></description>
			<content:encoded><![CDATA[<p>In January, I reflected on year 2009 as it pertained to my programming career. What had I accomplished?<br />
I thought long and hard about this. I didn't publish any kick-ass new websites. I didn't make any major contributions to an open source project. The crowning achievement of my year was a <a href="http://apps.facebook.com/typing-challenge/" onclick="pageTracker._trackPageview('/outgoing/apps.facebook.com/typing-challenge/?referer=');">Facebook app</a> that accidentally exploded in popularity when it was really just meant to be a "Hello World!" app to learn the Facebook API.<br />
But this made no sense -- I spent more time than I ever had in code over the past 365 days. </p>
<p>Somewhere along the way I lost sight of the goals. I did not become a programmer because I was amused with math, engineering, or manipulating computers. I became a programmer to create things that have a real impact on the world in some way, even if only slightly. When I first started programming, my code was hideous, insecure, and unmaintainable. But they worked. They had an input, and more importantly, they had an output. And that output did something useful. Why did the culmination of my last year of work have so little output?</p>
<p>The past year has been a great learning experience in other ways, of course. I learned Zend Framework inside and out. I built my own true MVC stack from scratch for learning purposes. I spent tons of time understanding different domain model implementations and formal ORM libraries. And now it's time to put that knowledge to use. I'm switching gears back to being a results-oriented developer. </p>
<p>This made me realize why developer managers push deadlines so hard. Ship your code. Perfect code is not perfect unless it's shipped.<br />
Understanding design trade-offs and cutting features is a skill, not an option.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.leakingabstraction.com/articles/over-engineering-syndrome-and-becoming-results-oriented/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Part II: Managing CSS and JavaScript files within a Zend Framework App</title>
		<link>http://www.leakingabstraction.com/tutorials/part-ii-managing-css-and-javascript-files-within-a-zend-framework-app/</link>
		<comments>http://www.leakingabstraction.com/tutorials/part-ii-managing-css-and-javascript-files-within-a-zend-framework-app/#comments</comments>
		<pubDate>Mon, 15 Feb 2010 07:22:57 +0000</pubDate>
		<dc:creator>Andy Baird</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[minifier]]></category>
		<category><![CDATA[packer]]></category>
		<category><![CDATA[Zend_View_Helper]]></category>

		<guid isPermaLink="false">http://www.leakingabstraction.com/?p=141</guid>
		<description><![CDATA[Since my first post seemed to garner a good amount of attention I thought I'd follow up with another post on how to optimize our CSS/JS view helper components a bit.
The biggest suggestion -- and rightfully so, was to minify or gzip the extra controller/action Javascript or CSS file.
It doesn't take a lot of imagination [...]]]></description>
			<content:encoded><![CDATA[<p>Since my first post seemed to garner a good amount of attention I thought I'd follow up with another post on how to optimize our CSS/JS view helper components a bit.</p>
<p>The biggest suggestion -- and rightfully so, was to minify or gzip the extra controller/action Javascript or CSS file.<br />
It doesn't take a lot of imagination to implement an improvement. There are several easy ways we can prevent the client (our users) from needing to download another CSS or JS file to view a particular controller action.</p>
<p>Firstly, we can get both the CSS and JS files to output in-line instead of loading as a separate file very easily:</p>
<p>File: <strong>/application/views/helpers/JavascriptHelper.php</strong></p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <br />
<span style="color: #000000; font-weight: bold;">class</span> Zend_View_Helper_JavascriptHelper <span style="color: #000000; font-weight: bold;">extends</span> Zend_View_Helper_Abstract<br />
<span style="color: #009900;">&#123;</span> &nbsp; <br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">function</span> javascriptHelper<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$request</span> <span style="color: #339933;">=</span> Zend_Controller_Front<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;">-&gt;</span><span style="color: #004000;">getRequest</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$file_uri</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'media/js/'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$request</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getControllerName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$request</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getActionName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'.js'</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><a href="http://www.php.net/file_exists" onclick="pageTracker._trackPageview('/outgoing/www.php.net/file_exists?referer=');"><span style="color: #990000;">file_exists</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$file_uri</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">view</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">headScript</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">appendScript</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$file_uri</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span></div></div>
<p>In the CSS helper, we'll use the HeadStyle helper instead of the HeadLink helper:</p>
<p>File: <strong>/application/views/helpers/CssHelper.php</strong></p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <br />
<span style="color: #000000; font-weight: bold;">class</span> Zend_View_Helper_CssHelper <span style="color: #000000; font-weight: bold;">extends</span> Zend_View_Helper_Abstract<br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">function</span> cssHelper<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$request</span> <span style="color: #339933;">=</span> Zend_Controller_Front<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;">-&gt;</span><span style="color: #004000;">getRequest</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$file_uri</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'media/css/'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$request</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getControllerName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$request</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getActionName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'.css'</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><a href="http://www.php.net/file_exists" onclick="pageTracker._trackPageview('/outgoing/www.php.net/file_exists?referer=');"><span style="color: #990000;">file_exists</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$file_uri</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">view</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">headStyle</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">appendStyle</span><span style="color: #009900;">&#40;</span><a href="http://www.php.net/file_get_contents" onclick="pageTracker._trackPageview('/outgoing/www.php.net/file_get_contents?referer=');"><span style="color: #990000;">file_get_contents</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$file_uri</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">view</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">headStyle</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span></div></div>
<p>If you were using the previous version of the CSS helper, make sure you update your layout to echo the HeadStyle helper. Be aware that the file references (e.g., background images) in your controller / action CSS files will now have a new base URL, so you will need to update accordingly.</p>
<h1>The next level - minifying the inline output</h1>
<p>The next obvious step is to minify the additional output. My first inclination was to use the CSS/JS minify library aptly titled <a href="http://code.google.com/p/minify/" onclick="pageTracker._trackPageview('/outgoing/code.google.com/p/minify/?referer=');">minify</a>, however, that does a lot more than we need. I'm not a big fan of adding large libraries for the sake of one function, so let's instead explore how we can create exactly what we need within our view helper.</p>
<p>A little more googling gets us to <a href="http://www.lateralcode.com/css-minifer/" onclick="pageTracker._trackPageview('/outgoing/www.lateralcode.com/css-minifer/?referer=');">this solution</a>. Sure, it's not perfect, but performing 90% of the necessary packing is good for me.<br />
My CSS view helper now turns into this:</p>
<p>File: <strong>/application/views/helpers/CssHelper.php</strong></p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;height:350px;"><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <br />
<span style="color: #000000; font-weight: bold;">class</span> Zend_View_Helper_CssHelper <span style="color: #000000; font-weight: bold;">extends</span> Zend_View_Helper_Abstract<br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">function</span> cssHelper<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$request</span> <span style="color: #339933;">=</span> Zend_Controller_Front<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;">-&gt;</span><span style="color: #004000;">getRequest</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$file_uri</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'media/css/'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$request</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getControllerName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$request</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getActionName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'.css'</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><a href="http://www.php.net/file_exists" onclick="pageTracker._trackPageview('/outgoing/www.php.net/file_exists?referer=');"><span style="color: #990000;">file_exists</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$file_uri</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$css</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">minify</span><span style="color: #009900;">&#40;</span><a href="http://www.php.net/file_get_contents" onclick="pageTracker._trackPageview('/outgoing/www.php.net/file_get_contents?referer=');"><span style="color: #990000;">file_get_contents</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$file_uri</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">view</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">headStyle</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">appendStyle</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$css</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">view</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">headStyle</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">function</span> minify<span style="color: #009900;">&#40;</span><span style="color: #000088;">$css</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// 90% minifying from http://www.lateralcode.com/css-minifer/</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$css</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/preg_replace" onclick="pageTracker._trackPageview('/outgoing/www.php.net/preg_replace?referer=');"><span style="color: #990000;">preg_replace</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'#\s+#'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">' '</span><span style="color: #339933;">,</span><span style="color: #000088;">$css</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$css</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/preg_replace" onclick="pageTracker._trackPageview('/outgoing/www.php.net/preg_replace?referer=');"><span style="color: #990000;">preg_replace</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'#/\*.*?\*/#s'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">''</span><span style="color: #339933;">,</span><span style="color: #000088;">$css</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$css</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/str_replace" onclick="pageTracker._trackPageview('/outgoing/www.php.net/str_replace?referer=');"><span style="color: #990000;">str_replace</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'; '</span><span style="color: #339933;">,</span><span style="color: #0000ff;">';'</span><span style="color: #339933;">,</span><span style="color: #000088;">$css</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$css</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/str_replace" onclick="pageTracker._trackPageview('/outgoing/www.php.net/str_replace?referer=');"><span style="color: #990000;">str_replace</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">': '</span><span style="color: #339933;">,</span><span style="color: #0000ff;">':'</span><span style="color: #339933;">,</span><span style="color: #000088;">$css</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$css</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/str_replace" onclick="pageTracker._trackPageview('/outgoing/www.php.net/str_replace?referer=');"><span style="color: #990000;">str_replace</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">' {'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'{'</span><span style="color: #339933;">,</span><span style="color: #000088;">$css</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$css</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/str_replace" onclick="pageTracker._trackPageview('/outgoing/www.php.net/str_replace?referer=');"><span style="color: #990000;">str_replace</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'{ '</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'{'</span><span style="color: #339933;">,</span><span style="color: #000088;">$css</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$css</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/str_replace" onclick="pageTracker._trackPageview('/outgoing/www.php.net/str_replace?referer=');"><span style="color: #990000;">str_replace</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">', '</span><span style="color: #339933;">,</span><span style="color: #0000ff;">','</span><span style="color: #339933;">,</span><span style="color: #000088;">$css</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$css</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/str_replace" onclick="pageTracker._trackPageview('/outgoing/www.php.net/str_replace?referer=');"><span style="color: #990000;">str_replace</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'} '</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'}'</span><span style="color: #339933;">,</span><span style="color: #000088;">$css</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$css</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/str_replace" onclick="pageTracker._trackPageview('/outgoing/www.php.net/str_replace?referer=');"><span style="color: #990000;">str_replace</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">';}'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'}'</span><span style="color: #339933;">,</span><span style="color: #000088;">$css</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> <a href="http://www.php.net/trim" onclick="pageTracker._trackPageview('/outgoing/www.php.net/trim?referer=');"><span style="color: #990000;">trim</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$css</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #009900;">&#125;</span></div></div>
<p>For the JS packer, we'll use <a href="http://dean.edwards.name/" onclick="pageTracker._trackPageview('/outgoing/dean.edwards.name/?referer=');">Dean Edward's</a> Javascript Packer that was ported to PHP by Nicolas Martin. You can download the class here:</p>
<p><a class="download-link" href="http://www.zendframeworkhelp.com/files/JavaScriptPacker.zip" onclick="pageTracker._trackPageview('/outgoing/www.zendframeworkhelp.com/files/JavaScriptPacker.zip?referer=');">Download Javascript Packer by Dean Edward<span> </span></a></p>
<ul>
<li style="list-style-type:none">&nbsp;</li>
</ul>
<p>I added the JS packer to <strong>/library/jspacker/JavaScriptPacker.php</strong>. I modify my JavaScript helper by doing the following:</p>
<p>File: <strong>/application/views/helpers/JavascriptHelper.php</strong></p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <br />
<span style="color: #000000; font-weight: bold;">class</span> Zend_View_Helper_JavascriptHelper <span style="color: #000000; font-weight: bold;">extends</span> Zend_View_Helper_Abstract<br />
<span style="color: #009900;">&#123;</span> &nbsp; <br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">function</span> javascriptHelper<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$request</span> <span style="color: #339933;">=</span> Zend_Controller_Front<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;">-&gt;</span><span style="color: #004000;">getRequest</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$file_uri</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'media/js/'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$request</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getControllerName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$request</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getActionName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'.js'</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><a href="http://www.php.net/file_exists" onclick="pageTracker._trackPageview('/outgoing/www.php.net/file_exists?referer=');"><span style="color: #990000;">file_exists</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$file_uri</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$javascript</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/file_get_contents" onclick="pageTracker._trackPageview('/outgoing/www.php.net/file_get_contents?referer=');"><span style="color: #990000;">file_get_contents</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$file_uri</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">require_once</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'jspacker/JavaScriptPacker.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$packer</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> JavaScriptPacker<span style="color: #009900;">&#40;</span><span style="color: #000088;">$javascript</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">view</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">headScript</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">appendScript</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$packer</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">pack</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">view</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">headScript</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span></div></div>
<p>The major disadvantage to this is debugging can be a pain when you don't have line numbers or variable names to reference. Thus, I added a conditional statement that only packs the Javascript if not in the development environment:</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000088;">$javascript</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/file_get_contents" onclick="pageTracker._trackPageview('/outgoing/www.php.net/file_get_contents?referer=');"><span style="color: #990000;">file_get_contents</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$file_uri</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>APPLICATION_ENV <span style="color: #339933;">!=</span> <span style="color: #0000ff;">'development'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$packer</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> JavaScriptPacker<span style="color: #009900;">&#40;</span><span style="color: #000088;">$javascript</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$javascript</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$packer</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">pack</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">view</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">headScript</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">appendScript</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$javascript</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></div>
<p>Presto! Auto-minifying, auto-packing inline Javascript and CSS only when we need it for our controller/actions.</p>
<p>Next steps? I suspect our next step is to add some server side caching so all this parsing doesn't happen in real time at the client's expense. Look for a short part 3 using Zend_Cache very soon.</p>
<p>Questions, comments? Please feel free to leave them below!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.leakingabstraction.com/tutorials/part-ii-managing-css-and-javascript-files-within-a-zend-framework-app/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Managing CSS and JavaScript files within a Zend Framework App</title>
		<link>http://www.leakingabstraction.com/tutorials/managing-css-and-javascript-files-within-a-zend-framework-app/</link>
		<comments>http://www.leakingabstraction.com/tutorials/managing-css-and-javascript-files-within-a-zend-framework-app/#comments</comments>
		<pubDate>Mon, 01 Feb 2010 23:26:21 +0000</pubDate>
		<dc:creator>Andy Baird</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Zend_View_Helper]]></category>

		<guid isPermaLink="false">http://www.zendframeworkhelp.com/?p=115</guid>
		<description><![CDATA[When I'm creating a large external facing website or application, one of the biggest messes I used to end up making was in my CSS and JavaScript files.
As a developer/designer (jack of all trades, master of none, if you will) I tend to stay away from some of the more common developer solutions that take [...]]]></description>
			<content:encoded><![CDATA[<p>When I'm creating a large external facing website or application, one of the biggest messes I used to end up making was in my CSS and JavaScript files.</p>
<p>As a developer/designer (jack of all trades, master of none, if you will) I tend to stay away from some of the more common developer solutions that take care of a lot of the design overhead (e.g., jQuery UI framework, Dojo, etc). Flexibility is paramount to good design -- boxing yourself into a specific layout for every page is bound to produce a boring, forgettable website. Design is highly underrated to developers, I believe a good aesthetic sense is a skill worth maturing for anyone who develops web applications. After all, you can have the most beautiful underlying code, but if it's presentation is anything short of beautiful it completely loses its "wow" factor.</p>
<p>Full design control usually means large, thousand plus line CSS files that equal serious pain when it comes to maintenance or building upon. If you don't namespace your selectors carefully you'll end up paying for it down the road. And heaven forbid you apply a default HTML tag styling. So, ranting aside, how do you maintain flexibility and still keep tidy CSS and JavaScript? My solution is to keep the very same directory/file structure that is used for the application for my CSS and JavaScript. The best part is by writing a very simple view helper, it's super easy to automate the proper head link and script file inclusions.</p>
<p>Here's what my CSS and JavaScript view helpers look like:</p>
<p>File: <strong>application/views/helpers/JavascriptHelper.php</strong></p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <br />
<span style="color: #000000; font-weight: bold;">class</span> Zend_View_Helper_JavascriptHelper <span style="color: #000000; font-weight: bold;">extends</span> Zend_View_Helper_Abstract<br />
<span style="color: #009900;">&#123;</span> &nbsp; <br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">function</span> javascriptHelper<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$request</span> <span style="color: #339933;">=</span> Zend_Controller_Front<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;">-&gt;</span><span style="color: #004000;">getRequest</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$file_uri</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'media/js/'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$request</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getControllerName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$request</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getActionName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'.js'</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><a href="http://www.php.net/file_exists" onclick="pageTracker._trackPageview('/outgoing/www.php.net/file_exists?referer=');"><span style="color: #990000;">file_exists</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$file_uri</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">view</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">headScript</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">appendFile</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$file_uri</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span></div></div>
<p>File: <strong>application/views/helpers/CssHelper.php</strong></p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <br />
<span style="color: #000000; font-weight: bold;">class</span> Zend_View_Helper_CssHelper <span style="color: #000000; font-weight: bold;">extends</span> Zend_View_Helper_Abstract<br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">function</span> cssHelper<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$request</span> <span style="color: #339933;">=</span> Zend_Controller_Front<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;">-&gt;</span><span style="color: #004000;">getRequest</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$file_uri</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'media/css/'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$request</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getControllerName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$request</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getActionName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'.css'</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><a href="http://www.php.net/file_exists" onclick="pageTracker._trackPageview('/outgoing/www.php.net/file_exists?referer=');"><span style="color: #990000;">file_exists</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$file_uri</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">view</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">headLink</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">appendStylesheet</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$file_uri</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">view</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">headLink</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span></div></div>
<p>With that done, add the helper to your layout in the <HEAD> section:</p>
<p>File: <strong>application/layouts/scripts/layout.phtml</strong></p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&lt;head&gt;<br />
&nbsp; &nbsp; &lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt; <br />
&nbsp; &nbsp; &lt;title&gt;My app title&lt;/title&gt;<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">&lt;?</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">headLink</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">appendStylesheet</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/media/css/global.css'</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">&lt;?</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">headLink</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">appendStylesheet</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/media/css/iefix.css'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'screen'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'lt IE 7'</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">&lt;?=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">cssHelper</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span> &nbsp; <br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">&lt;?</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">headScript</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">appendFile</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/media/js/jquery-1.3.2.min.js'</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">&lt;?</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">headScript</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">appendFile</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/media/js/global.js'</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">&lt;?</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">javascriptHelper</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">&lt;?=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">headScript</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><br />
&lt;/head&gt;</div></div>
<p>Now, anytime a controller action is invoked it will look for a javascript and css file in the same controller/action file path. In the above examples I've hard-coded the CSS and Javascript parent directories (/public/media for me) directly in to the code, but this would be pretty easy if you wanted to throw it in a config file or something instead. Otherwise just change to your preferred directory and your good to go.</p>
<p>The next thing I'd like to explore is automatically packing/minifying all CSS and Javascript into one file (or possibly outputting them directly to the layout in-line) and then caching the results of that to optimize bandwidth usage. If I ever have the luxury of that being a priority, that is <img src='http://www.leakingabstraction.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.leakingabstraction.com/tutorials/managing-css-and-javascript-files-within-a-zend-framework-app/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>New domain, mission statement</title>
		<link>http://www.leakingabstraction.com/misc/new-domain-mission-statement/</link>
		<comments>http://www.leakingabstraction.com/misc/new-domain-mission-statement/#comments</comments>
		<pubDate>Mon, 01 Feb 2010 22:44:06 +0000</pubDate>
		<dc:creator>Andy Baird</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://www.leakingabstraction.com/?p=129</guid>
		<description><![CDATA[I've decided to change the name of this blog from zendframeworkhelp.com to leakingabstraction.com (leakyabstractions.com was of course taken).
I did this because the name implied that I am some Zend Framework guru -- which I am not, so I have changed the name to something more fitting. Of course, as I code and learn new things, [...]]]></description>
			<content:encoded><![CDATA[<p>I've decided to change the name of this blog from zendframeworkhelp.com to leakingabstraction.com (leakyabstractions.com was of course taken).</p>
<p>I did this because the name implied that I am some Zend Framework guru -- which I am not, so I have changed the name to something more fitting. Of course, as I code and learn new things, I will post articles/tutorials here for all. Nothing changes are far as that goes.It felt a little bit arrogant to represent this website and myself as an expert when I am still learning so much from the true experts. Truthfully, my goal is to suck up as much knowledge as I can and then spit out all the good parts. The "tutorials" and "articles" section at the top will remain and I will continue to contribute to both, although there may be more general/opinion posts in the future.</p>
<p>If you want to know what inspired the name, have a read of <a href="http://www.joelonsoftware.com/articles/LeakyAbstractions.html" onclick="pageTracker._trackPageview('/outgoing/www.joelonsoftware.com/articles/LeakyAbstractions.html?referer=');">this</a> famous <a href="http://www.joelonsoftware.com" onclick="pageTracker._trackPageview('/outgoing/www.joelonsoftware.com?referer=');">Joel on Software</a> article.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.leakingabstraction.com/misc/new-domain-mission-statement/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Running scripts in Zend Framework</title>
		<link>http://www.leakingabstraction.com/tutorials/running-scripts-in-zend-framework/</link>
		<comments>http://www.leakingabstraction.com/tutorials/running-scripts-in-zend-framework/#comments</comments>
		<pubDate>Sun, 31 Jan 2010 00:10:39 +0000</pubDate>
		<dc:creator>Andy Baird</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[CRON]]></category>
		<category><![CDATA[scripts]]></category>
		<category><![CDATA[Zend_Application]]></category>

		<guid isPermaLink="false">http://www.zendframeworkhelp.com/?p=117</guid>
		<description><![CDATA[It's always been a bit confusing to me where and how to execute scripts within my Zend Framework applications. Often times I would just initialize the autoloader and the classes myself in the script file itself.  Since the existence of Zend_Application, this has become a whole lot easier.
First, I create a folder called "scripts" in [...]]]></description>
			<content:encoded><![CDATA[<p>It's always been a bit confusing to me where and how to execute scripts within my Zend Framework applications. Often times I would just initialize the autoloader and the classes myself in the script file itself.  Since the existence of Zend_Application, this has become a whole lot easier.</p>
<p>First, I create a folder called "scripts" in my application directory. This is an ideal location for scripts because it's outside of the Apache HTTP root which means we don't need to worry about remote execution. We can also easily point CRON jobs to this location instead of running some fangled CRON job to cURL a particular URL (Yes, I'm guilty of this, sadly).</p>
<p>Now, at the top of any script we write, add the following:</p>
<p>File: <strong>/application/scripts/anyscriptyouwrite.php</strong></p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><a href="http://www.php.net/define" onclick="pageTracker._trackPageview('/outgoing/www.php.net/define?referer=');"><span style="color: #990000;">define</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'APPLICATION_ENV'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'script'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">require_once</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'../../httpdocs/index.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></div>
<p>This sets our application environment to the "script" environment. Now, we will customize our Bootstrapper when running scripts by editing the index.php in the web root:</p>
<p>File: <strong>/public/index.php</strong></p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>APPLICATION_ENV <span style="color: #339933;">==</span> <span style="color: #0000ff;">'script'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$application</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">bootstrap</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Db'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$application</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">bootstrap</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Registry'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">/* ..etc.. */</span><br />
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$application</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">bootstrap</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">-&gt;</span><span style="color: #004000;">run</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span></div></div>
<p>Notice, we don't ever call the run() method, so the front controller never gets instantiated. This allows us to explicitly declare each resource we want to setup an environment more ideal for scripting.<br />
Another cool side effect of using the APPLICATION_ENV is we can specify script-specific settings in our application.ini:</p>
<p>File: <strong>/application/configs/application.ini</strong></p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #009900;">&#91;</span>script <span style="color: #339933;">:</span> production <span style="color: #009900;">&#93;</span><br />
resources<span style="color: #339933;">.</span>db<span style="color: #339933;">.</span>adapter <span style="color: #339933;">=</span> PDO_MYSQL<br />
resources<span style="color: #339933;">.</span>db<span style="color: #339933;">.</span>params<span style="color: #339933;">.</span>host <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;hostname&quot;</span><br />
resources<span style="color: #339933;">.</span>db<span style="color: #339933;">.</span>params<span style="color: #339933;">.</span>username <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;username&quot;</span><br />
resources<span style="color: #339933;">.</span>db<span style="color: #339933;">.</span>params<span style="color: #339933;">.</span>password <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;password&quot;</span><br />
resources<span style="color: #339933;">.</span>db<span style="color: #339933;">.</span>params<span style="color: #339933;">.</span>dbname <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;dbname&quot;</span></div></div>
]]></content:encoded>
			<wfw:commentRss>http://www.leakingabstraction.com/tutorials/running-scripts-in-zend-framework/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Resources for Zend Framework</title>
		<link>http://www.leakingabstraction.com/misc/resources-for-zend-framework/</link>
		<comments>http://www.leakingabstraction.com/misc/resources-for-zend-framework/#comments</comments>
		<pubDate>Sat, 09 Jan 2010 08:49:34 +0000</pubDate>
		<dc:creator>Andy Baird</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[Links]]></category>
		<category><![CDATA[Resources]]></category>

		<guid isPermaLink="false">http://www.zendframeworkhelp.com/?p=98</guid>
		<description><![CDATA[One of the most challenging aspects of the Zend Framework is that while there is a large volume of resources available for Zend Framework, sifting through this to get answers to specific problems can be tough. This is partially the fault of the nature of the framework -- a very uncoupled library means there is [...]]]></description>
			<content:encoded><![CDATA[<p>One of the most challenging aspects of the Zend Framework is that while there is a large volume of resources available for Zend Framework, sifting through this to get answers to specific problems can be tough. This is partially the fault of the nature of the framework -- a very uncoupled library means there is a lot of ways to implement it, many of them undocumented.</p>
<p>If you dig deep enough, though, you'll find that someone out there has probably tried to do whatever  it is you are trying to accomplish -- or at least something like it. Here's my list of the top resources I use to reach solutions for my Zend Framework problems.</p>
<ol>
<li><a href="http://framework.zend.com/manual/en/" onclick="pageTracker._trackPageview('/outgoing/framework.zend.com/manual/en/?referer=');">The Reference Guide</a> - Duh, right? It's #1 on my list, and it should be #1 on yours. If it isn't, are you sure you're reading it fully? I can't tell you how many newbies I've talked to that simply have not read the appropriate reference guide section on the functionality they are asking about. It's not perfect and it has some holes, but it is by far the most definitive resource.</li>
<li><span style="color: #ff0000;"><strong>EDIT</strong></span>: As the much respected <a href="http://weierophinney.net/matthew/" onclick="pageTracker._trackPageview('/outgoing/weierophinney.net/matthew/?referer=');">Matthew Weier O`Phinney</a> points out in the comments, I've forgotten one of the best resources out there: The <a href="http://framework.zend.com/wiki/display/ZFDEV/Contributing+to+Zend+Framework#ContributingtoZendFramework-Subscribetotheappropriatemailinglists" onclick="pageTracker._trackPageview('/outgoing/framework.zend.com/wiki/display/ZFDEV/Contributing+to+Zend+Framework_ContributingtoZendFramework-Subscribetotheappropriatemailinglists?referer=');">mailing lists</a>. Take your pick or just sign-up to fw-general@. You may even end up with a reply from the author of the component you're dealing with.</li>
<li><a href="http://stackoverflow.com/" onclick="pageTracker._trackPageview('/outgoing/stackoverflow.com/?referer=');">Stack Overflow</a> - Stack Overflow is a Q&amp;A site full of knowledgeable developers. My favorite part about Stack Overflow is developers that otherwise have no concrete online identity such as a blog or twitter will respond to posts. There are many knowledgeable "lurkers" who come out of the wood-works and often have clever solutions to problems that I wouldn't find on Google. Also, there are even some ZF contributors such as Bill Karwin who will personally respond to your questions.</li>
<li><a href="http://www.survivethedeepend.com/zendframeworkbook/en/1.0" onclick="pageTracker._trackPageview('/outgoing/www.survivethedeepend.com/zendframeworkbook/en/1.0?referer=');">Surviving the deep end</a> - After I read this, I could barely go back to my Zend apps in progress without completely restarting them from ground up. If MVC was ever unclear to you before reading this, read this now. Especially the section on <a href="http://www.survivethedeepend.com/zendframeworkbook/en/1.0/the.model" onclick="pageTracker._trackPageview('/outgoing/www.survivethedeepend.com/zendframeworkbook/en/1.0/the.model?referer=');">controllers and models</a>.</li>
<li><a href="http://www.zendframeworkinaction.com/" onclick="pageTracker._trackPageview('/outgoing/www.zendframeworkinaction.com/?referer=');">Zend Framework in Action</a> - Although intended for the Zend Framework 1.0 release, the concrete real-world examples it provides for some of the framework's most core classes (<code class="codecolorer php default"><span class="php"><a href="http://framework.zend.com/manual/en/zend.controller.html" onclick="pageTracker._trackPageview('/outgoing/framework.zend.com/manual/en/zend.controller.html?referer=');"><span style="">Zend_Controller</span></a></span></code>, <code class="codecolorer php default"><span class="php"><a href="http://framework.zend.com/manual/en/zend.auth.html" onclick="pageTracker._trackPageview('/outgoing/framework.zend.com/manual/en/zend.auth.html?referer=');"><span style="">Zend_Auth</span></a></span></code>, <code class="codecolorer php default"><span class="php"><a href="http://framework.zend.com/manual/en/zend.acl.html" onclick="pageTracker._trackPageview('/outgoing/framework.zend.com/manual/en/zend.acl.html?referer=');"><span style="">Zend_Acl</span></a></span></code>, <code class="codecolorer php default"><span class="php"><a href="http://framework.zend.com/manual/en/zend.db.html" onclick="pageTracker._trackPageview('/outgoing/framework.zend.com/manual/en/zend.db.html?referer=');"><span style="">Zend_Db</span></a></span></code>) is still relevant.</li>
<li><a href="http://webchat.freenode.net/" onclick="pageTracker._trackPageview('/outgoing/webchat.freenode.net/?referer=');">IRC</a> - This outdated protocol still thrives among hardcore developers, and PHP programmers are no exception. Join the #zftalk channel and ask your question. There are usually attentive and experienced users there who have probably ran into the problems you're facing. Several large ZF contributors also lurk here as well.</li>
<li><a href="http://twitter.com/#search?q=%23zf" onclick="pageTracker._trackPageview('/outgoing/twitter.com/_search?q=_23zf&amp;referer=');">Twitter</a> - I'll admit, it's not my cup of tea but it's been a great resource for others. Ask your question, throw on the <a href="http://twitter.com/#search?q=%23zf" onclick="pageTracker._trackPageview('/outgoing/twitter.com/_search?q=_23zf&amp;referer=');">#zf</a> hash tag, and cross your fingers.</li>
<li>Blogs. Although most of the relevant ones will popup in a Google search, there's a couple I subscribe to regularly (that you can see on my links section to the right). If it's on my blogroll, it's because I feel any new post they make will be relevant and insightful. Each one is worth checking out.</li>
<li>and last but not least... nothing explains the code in more detail than the code itself. One of the most important lessons you can ever learn in programming is nothing teaches you like diving into the code yourself.  Although the task can seem daunting at first, it's often a better solution than an endless Google search or waiting for answer.</li>
</ol>
<p><span style="color: #ff0000;"><br />
</span></p>
<p>Anyways, hope this helps someone. Maybe eventually this site can be added to the list above !</p>
]]></content:encoded>
			<wfw:commentRss>http://www.leakingabstraction.com/misc/resources-for-zend-framework/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Zend_Db: query(), fetch methods, and Zend_Db_Select</title>
		<link>http://www.leakingabstraction.com/tutorials/zend_db-query-fetch-methods-and-zend_db_select/</link>
		<comments>http://www.leakingabstraction.com/tutorials/zend_db-query-fetch-methods-and-zend_db_select/#comments</comments>
		<pubDate>Sat, 09 Jan 2010 07:36:32 +0000</pubDate>
		<dc:creator>Andy Baird</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Zend_Db]]></category>
		<category><![CDATA[Zend_Db_Select]]></category>

		<guid isPermaLink="false">http://www.zendframeworkhelp.com/?p=59</guid>
		<description><![CDATA[Zend_Db provides several methods for querying a database. They range from a simple query wrapper to programmatically. Say we have database object $db = Zend_Db_Table::getDefaultAdapter&#40;&#41;:
 query() - Will return the results of any SQL query.
 fetchRow() - Will return only the first row of the result set.
 fetchCol() - Will return only one column (the [...]]]></description>
			<content:encoded><![CDATA[<p><code class="codecolorer php default"><span class="php"><a href="http://framework.zend.com/manual/en/zend.db.html" onclick="pageTracker._trackPageview('/outgoing/framework.zend.com/manual/en/zend.db.html?referer=');"><span style="">Zend_Db</span></a></span></code> provides several methods for querying a database. They range from a simple query wrapper to programmatically. Say we have database object <code class="codecolorer php default"><span class="php"><span style="color: #000088;">$db</span> <span style="color: #339933;">=</span> <a href="http://framework.zend.com/manual/en/zend.db.table.html" onclick="pageTracker._trackPageview('/outgoing/framework.zend.com/manual/en/zend.db.table.html?referer=');"><span style="">Zend_Db_Table</span></a><span style="color: #339933;">::</span><span style="color: #004000;">getDefaultAdapter</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span></span></code>:</p>
<p><img class="size-full wp-image-62 alignnone" style="vertical-align: text-top;" title="table-select-all" src="http://www.zendframeworkhelp.com/wp-content/uploads/2010/01/table-select-all.png" alt="" width="16" height="16" /> query() - Will return the results of any SQL query.</p>
<p><img class="size-full wp-image-65 alignnone" title="table-select-row" src="http://www.zendframeworkhelp.com/wp-content/uploads/2010/01/table-select-row.png" alt="" width="16" height="16" /> fetchRow() - Will return only the first row of the result set.</p>
<p><img class="size-full wp-image-64 alignnone" title="table-select-column" src="http://www.zendframeworkhelp.com/wp-content/uploads/2010/01/table-select-column.png" alt="" width="16" height="16" /> fetchCol() - Will return only one column (the first one if your select statement will be used) as an array.</p>
<p><img class="size-full wp-image-63 alignnone" title="table-select" src="http://www.zendframeworkhelp.com/wp-content/uploads/2010/01/table-select.png" alt="" width="16" height="16" /> fetchOne() - Will return only the value of the first column of the first row of the query.</p>
<p>These methods return row objects wherever possible (for query(), fetchRow(), and fetchCol()). You can change this to an array by setting the fetch mode before executing the SQL:</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000088;">$db</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setFetchMode</span><span style="color: #009900;">&#40;</span><a href="http://framework.zend.com/manual/en/zend.db.html" onclick="pageTracker._trackPageview('/outgoing/framework.zend.com/manual/en/zend.db.html?referer=');"><span style="">Zend_Db</span></a><span style="color: #339933;">::</span><span style="color: #004000;">FETCH_ARRAY</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></div>
<p>Or, if you just want to get your results as an array in the first place, you can use <code class="codecolorer php default"><span class="php"><span style="color: #000088;">$db</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">fetchAssoc</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$query</span><span style="color: #009900;">&#41;</span></span></code>.</p>
<h2>Creating queries programmatically with Zend_Db_Select</h2>
<p>A <code class="codecolorer php default"><span class="php"><a href="http://framework.zend.com/manual/en/zend.db.select.html" onclick="pageTracker._trackPageview('/outgoing/framework.zend.com/manual/en/zend.db.select.html?referer=');"><span style="">Zend_Db_Select</span></a></span></code> statement produces SQL that is correct based on the adapter you are using. It also takes care of things you probably don't ever bother to do when you write your own queries, such as deliberately expressing all tables along with their columns and properly escaping all table and column names. <code class="codecolorer php default"><span class="php"><a href="http://framework.zend.com/manual/en/zend.db.select.html" onclick="pageTracker._trackPageview('/outgoing/framework.zend.com/manual/en/zend.db.select.html?referer=');"><span style="">Zend_Db_Select</span></a></span></code> ultimately returns this query, so usage is simple:</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000088;">$db</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">fetchRow</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$db</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">select</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">from</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'sample'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></div>
<p>In this case, <code class="codecolorer php default"><span class="php"><span style="color: #000088;">$db</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">select</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">from</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'sample'</span><span style="color: #009900;">&#41;</span></span></code> returns the following string:</p>
<div class="codecolorer-container sql default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="sql codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #993333; font-weight: bold;">SELECT</span> <span style="color: #ff0000;">`sample`</span><span style="color: #66cc66;">.*</span> <span style="color: #993333; font-weight: bold;">FROM</span> <span style="color: #ff0000;">`sample`</span></div></div>
<p>We can add parameters to our select statement easily:</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000088;">$select</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$db</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">select</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">from</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'sample'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$select</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">where</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'id=100'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$select</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">order</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'id DESC'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></div>
<p>Which produces:</p>
<div class="codecolorer-container sql default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="sql codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #993333; font-weight: bold;">SELECT</span> <span style="color: #ff0000;">`sample`</span><span style="color: #66cc66;">.*</span> <span style="color: #993333; font-weight: bold;">FROM</span> <span style="color: #ff0000;">`sample`</span> <span style="color: #993333; font-weight: bold;">WHERE</span> <span style="color: #66cc66;">&#40;</span>id<span style="color: #66cc66;">=</span>100<span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">ORDER</span> <span style="color: #993333; font-weight: bold;">BY</span> <span style="color: #ff0000;">`id`</span> <span style="color: #993333; font-weight: bold;">DESC</span></div></div>
<p>With a little more <a href="http://framework.zend.com/manual/en/zend.db.select.html" onclick="pageTracker._trackPageview('/outgoing/framework.zend.com/manual/en/zend.db.select.html?referer=');">research</a>, you will quickly discover that you can perform nearly any non-complex query with <code class="codecolorer php default"><span class="php"><a href="http://framework.zend.com/manual/en/zend.db.select.html" onclick="pageTracker._trackPageview('/outgoing/framework.zend.com/manual/en/zend.db.select.html?referer=');"><span style="">Zend_Db_Select</span></a></span></code>.</p>
<h2>When to use Zend_Db_Select and writing SQL directly</h2>
<p>The first thing you probably took away from Zend_Db_Select (at least I did) is the fact that it makes writing really simple queries way more complicated than they should be.</p>
<p>And, well, you're right. It's hard to fight the instinct that using Zend_Db_Select feels like the right thing to do - it feels like it's the convention that a good programmer is <strong>supposed </strong>to follow. The reality is, for your application, you probably don't need to use it. Here's the list of conditions I came up with where I use Zend_Db_Select over writing the query directly.</p>
<ul>
<li>You are writing an application that needs to run on top of different types of RDBMS?</li>
<li>You are writing a piece of code that you want to use in several different applications where the environments are unknown.</li>
<li>You are writing a query that will be modified based on different logic conditions.</li>
</ul>
<p>For the average application, you probably won't find yourself needing Zend_Db_Select that much. That said, when you do need it, nothing can beat it for the level of abstraction it provides.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.leakingabstraction.com/tutorials/zend_db-query-fetch-methods-and-zend_db_select/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using Zend_Db standalone</title>
		<link>http://www.leakingabstraction.com/tutorials/using-zend_db-standalone/</link>
		<comments>http://www.leakingabstraction.com/tutorials/using-zend_db-standalone/#comments</comments>
		<pubDate>Tue, 05 Jan 2010 22:01:47 +0000</pubDate>
		<dc:creator>Andy Baird</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Zend Framework]]></category>
		<category><![CDATA[Zend_Db]]></category>

		<guid isPermaLink="false">http://www.zendframeworkhelp.com/?p=12</guid>
		<description><![CDATA[If there is one class I had to pick out of the ZF library as the crown jewel, it would without a doubt be Zend_Db.
I rarely touch a PHP application or script that interacts with any database without utilizing this class.
Let's go over the quick list of why it's my fave:

It automatically wraps PDO extensions [...]]]></description>
			<content:encoded><![CDATA[<p>If there is one class I had to pick out of the ZF library as the crown jewel, it would without a doubt be <a href="http://framework.zend.com/manual/en/zend.db.html" onclick="pageTracker._trackPageview('/outgoing/framework.zend.com/manual/en/zend.db.html?referer=');">Zend_Db</a>.<br />
I rarely touch a PHP application or script that interacts with any database without utilizing this class.</p>
<p>Let's go over the quick list of why it's my fave:</p>
<ul>
<li>It automatically wraps PDO extensions and normalizes them as best as possible across different types of databases (in simple terms: change from a MySQL database to an MS SQL or PostgreSQL database with minimal code change)</li>
<li>It sanitizes data input for you automatically (as long as you use it correctly)</li>
<li>You can quickly grab results in array or object form without performing any post query operations.</li>
<li>Provides methods for programatically creating queries</li>
</ul>
<p>On top of that, it's easily decoupled from the rest of the library. Let's start out by ripping out Zend/Db.php and the Zend/Db folder and dropping it in our app.</p>
<h2>Initializing the database connection</h2>
<p>Now, in our settings / boilerplate file let's initialize the database adapter. The database adapter uses a lazy connection (meaning it doesn't actually connect to the database until you perform a query with it) by default. This makes the application settings a perfect place to setup our database object.</p>
<pre>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000088;">$db</span> <span style="color: #339933;">=</span> <a href="http://framework.zend.com/manual/en/zend.db.html" onclick="pageTracker._trackPageview('/outgoing/framework.zend.com/manual/en/zend.db.html?referer=');"><span style="">Zend_Db</span></a><span style="color: #339933;">::</span><span style="color: #004000;">factory</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Pdo_Mysql'</span><span style="color: #339933;">,</span> <a href="http://www.php.net/array" onclick="pageTracker._trackPageview('/outgoing/www.php.net/array?referer=');"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><br />
&nbsp; &nbsp; <span style="color: #0000ff;">'host'</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'localhost'</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; <span style="color: #0000ff;">'username'</span> &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'database_username'</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; <span style="color: #0000ff;">'password'</span> &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'database_password'</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; <span style="color: #0000ff;">'dbname'</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'database'</span><br />
<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></div>
</pre>
<p>That's easy enough. If the application is simple and you plan on referencing the $db variable every time you want to make a query, you can stop right there. If you plan on using the database connection within a function or class scope, you don't have to re-initialize it every time (or use icky global variables). Zend_Db_Table comes with a static function for setting the default database adapter.</p>
<pre>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #b1b100;">require_once</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Zend/Db/Table.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<a href="http://framework.zend.com/manual/en/zend.db.table.html" onclick="pageTracker._trackPageview('/outgoing/framework.zend.com/manual/en/zend.db.table.html?referer=');"><span style="">Zend_Db_Table</span></a><span style="color: #339933;">::</span><span style="color: #004000;">setDefaultAdapter</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$db</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></div>
</pre>
<p>And now within our classes or functions, we can easily call it at any time:</p>
<pre>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">class</span> MyClass <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$db</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">function</span> __construct<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$db</span> <span style="color: #339933;">=</span> <a href="http://framework.zend.com/manual/en/zend.db.table.html" onclick="pageTracker._trackPageview('/outgoing/framework.zend.com/manual/en/zend.db.table.html?referer=');"><span style="">Zend_Db_Table</span></a><span style="color: #339933;">::</span><span style="color: #004000;">getDefaultAdapter</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span></div></div>
</pre>
<p>Presto. Persistent database object any time we need it in our application / script.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.leakingabstraction.com/tutorials/using-zend_db-standalone/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hacking Geshi syntax highlighter to recognize Zend Framework classes</title>
		<link>http://www.leakingabstraction.com/articles/hacking-geshi-syntax-highlighter-to-recognize-zend-framework-classes/</link>
		<comments>http://www.leakingabstraction.com/articles/hacking-geshi-syntax-highlighter-to-recognize-zend-framework-classes/#comments</comments>
		<pubDate>Tue, 05 Jan 2010 21:43:00 +0000</pubDate>
		<dc:creator>Andy Baird</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[geshi]]></category>
		<category><![CDATA[manual]]></category>
		<category><![CDATA[syntax-highlighter]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[wp-plugin]]></category>

		<guid isPermaLink="false">http://www.zendframeworkhelp.com/?p=32</guid>
		<description><![CDATA[This is kind of off-topic, but pretty neat. I was able to modify my Geshi WordPress plugin (called CodeColorer) to recognize Zend classes and link to the proper ZF Manual page. Example:
//Example of automatic Zend_ class linkage!
Zend_Acl Zend_Amf Zend_Application Zend_Auth Zend_Cache
Zend_Captcha Zend_CodeGenerator Zend_Config Zend_Config_Writer Zend_Console_Getopt
Zend_Controller Zend_Currency Zend_Date Zend_Db Zend_Debug
Zend_Dojo Zend_Dom Zend_Exception Zend_Feed Zend_File
Zend_Filter Zend_Form Zend_Gdata [...]]]></description>
			<content:encoded><![CDATA[<p>This is kind of off-topic, but pretty neat. I was able to modify my <a href="http://qbnz.com/highlighter/" onclick="pageTracker._trackPageview('/outgoing/qbnz.com/highlighter/?referer=');">Geshi</a> WordPress plugin (called <a href="http://wordpress.org/extend/plugins/codecolorer/" onclick="pageTracker._trackPageview('/outgoing/wordpress.org/extend/plugins/codecolorer/?referer=');">CodeColorer</a>) to recognize Zend classes and link to the proper ZF Manual page. Example:</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;">//Example of automatic Zend_ class linkage!</span><br />
<a href="http://framework.zend.com/manual/en/zend.acl.html" onclick="pageTracker._trackPageview('/outgoing/framework.zend.com/manual/en/zend.acl.html?referer=');"><span style="">Zend_Acl</span></a> <a href="http://framework.zend.com/manual/en/zend.amf.html" onclick="pageTracker._trackPageview('/outgoing/framework.zend.com/manual/en/zend.amf.html?referer=');"><span style="">Zend_Amf</span></a> <a href="http://framework.zend.com/manual/en/zend.application.html" onclick="pageTracker._trackPageview('/outgoing/framework.zend.com/manual/en/zend.application.html?referer=');"><span style="">Zend_Application</span></a> <a href="http://framework.zend.com/manual/en/zend.auth.html" onclick="pageTracker._trackPageview('/outgoing/framework.zend.com/manual/en/zend.auth.html?referer=');"><span style="">Zend_Auth</span></a> <a href="http://framework.zend.com/manual/en/zend.cache.html" onclick="pageTracker._trackPageview('/outgoing/framework.zend.com/manual/en/zend.cache.html?referer=');"><span style="">Zend_Cache</span></a><br />
<a href="http://framework.zend.com/manual/en/zend.captcha.html" onclick="pageTracker._trackPageview('/outgoing/framework.zend.com/manual/en/zend.captcha.html?referer=');"><span style="">Zend_Captcha</span></a> <a href="http://framework.zend.com/manual/en/zend.codegenerator.html" onclick="pageTracker._trackPageview('/outgoing/framework.zend.com/manual/en/zend.codegenerator.html?referer=');"><span style="">Zend_CodeGenerator</span></a> <a href="http://framework.zend.com/manual/en/zend.config.html" onclick="pageTracker._trackPageview('/outgoing/framework.zend.com/manual/en/zend.config.html?referer=');"><span style="">Zend_Config</span></a> <a href="http://framework.zend.com/manual/en/zend.config.writer.html" onclick="pageTracker._trackPageview('/outgoing/framework.zend.com/manual/en/zend.config.writer.html?referer=');"><span style="">Zend_Config_Writer</span></a> <a href="http://framework.zend.com/manual/en/zend.console.getopt.html" onclick="pageTracker._trackPageview('/outgoing/framework.zend.com/manual/en/zend.console.getopt.html?referer=');"><span style="">Zend_Console_Getopt</span></a><br />
<a href="http://framework.zend.com/manual/en/zend.controller.html" onclick="pageTracker._trackPageview('/outgoing/framework.zend.com/manual/en/zend.controller.html?referer=');"><span style="">Zend_Controller</span></a> <a href="http://framework.zend.com/manual/en/zend.currency.html" onclick="pageTracker._trackPageview('/outgoing/framework.zend.com/manual/en/zend.currency.html?referer=');"><span style="">Zend_Currency</span></a> <a href="http://framework.zend.com/manual/en/zend.date.html" onclick="pageTracker._trackPageview('/outgoing/framework.zend.com/manual/en/zend.date.html?referer=');"><span style="">Zend_Date</span></a> <a href="http://framework.zend.com/manual/en/zend.db.html" onclick="pageTracker._trackPageview('/outgoing/framework.zend.com/manual/en/zend.db.html?referer=');"><span style="">Zend_Db</span></a> <a href="http://framework.zend.com/manual/en/zend.debug.html" onclick="pageTracker._trackPageview('/outgoing/framework.zend.com/manual/en/zend.debug.html?referer=');"><span style="">Zend_Debug</span></a><br />
<a href="http://framework.zend.com/manual/en/zend.dojo.html" onclick="pageTracker._trackPageview('/outgoing/framework.zend.com/manual/en/zend.dojo.html?referer=');"><span style="">Zend_Dojo</span></a> <a href="http://framework.zend.com/manual/en/zend.dom.html" onclick="pageTracker._trackPageview('/outgoing/framework.zend.com/manual/en/zend.dom.html?referer=');"><span style="">Zend_Dom</span></a> <a href="http://framework.zend.com/manual/en/zend.exception.html" onclick="pageTracker._trackPageview('/outgoing/framework.zend.com/manual/en/zend.exception.html?referer=');"><span style="">Zend_Exception</span></a> <a href="http://framework.zend.com/manual/en/zend.feed.html" onclick="pageTracker._trackPageview('/outgoing/framework.zend.com/manual/en/zend.feed.html?referer=');"><span style="">Zend_Feed</span></a> <a href="http://framework.zend.com/manual/en/zend.file.html" onclick="pageTracker._trackPageview('/outgoing/framework.zend.com/manual/en/zend.file.html?referer=');"><span style="">Zend_File</span></a><br />
<a href="http://framework.zend.com/manual/en/zend.filter.html" onclick="pageTracker._trackPageview('/outgoing/framework.zend.com/manual/en/zend.filter.html?referer=');"><span style="">Zend_Filter</span></a> <a href="http://framework.zend.com/manual/en/zend.form.html" onclick="pageTracker._trackPageview('/outgoing/framework.zend.com/manual/en/zend.form.html?referer=');"><span style="">Zend_Form</span></a> <a href="http://framework.zend.com/manual/en/zend.gdata.html" onclick="pageTracker._trackPageview('/outgoing/framework.zend.com/manual/en/zend.gdata.html?referer=');"><span style="">Zend_Gdata</span></a> <a href="http://framework.zend.com/manual/en/zend.http.html" onclick="pageTracker._trackPageview('/outgoing/framework.zend.com/manual/en/zend.http.html?referer=');"><span style="">Zend_Http</span></a> <a href="http://framework.zend.com/manual/en/zend.infocard.html" onclick="pageTracker._trackPageview('/outgoing/framework.zend.com/manual/en/zend.infocard.html?referer=');"><span style="">Zend_InfoCard</span></a><br />
<a href="http://framework.zend.com/manual/en/zend.json.html" onclick="pageTracker._trackPageview('/outgoing/framework.zend.com/manual/en/zend.json.html?referer=');"><span style="">Zend_Json</span></a> <a href="http://framework.zend.com/manual/en/zend.layout.html" onclick="pageTracker._trackPageview('/outgoing/framework.zend.com/manual/en/zend.layout.html?referer=');"><span style="">Zend_Layout</span></a> <a href="http://framework.zend.com/manual/en/zend.ldap.html" onclick="pageTracker._trackPageview('/outgoing/framework.zend.com/manual/en/zend.ldap.html?referer=');"><span style="">Zend_Ldap</span></a> <a href="http://framework.zend.com/manual/en/zend.loader.html" onclick="pageTracker._trackPageview('/outgoing/framework.zend.com/manual/en/zend.loader.html?referer=');"><span style="">Zend_Loader</span></a> <a href="http://framework.zend.com/manual/en/zend.locale.html" onclick="pageTracker._trackPageview('/outgoing/framework.zend.com/manual/en/zend.locale.html?referer=');"><span style="">Zend_Locale</span></a><br />
<a href="http://framework.zend.com/manual/en/zend.log.html" onclick="pageTracker._trackPageview('/outgoing/framework.zend.com/manual/en/zend.log.html?referer=');"><span style="">Zend_Log</span></a> <a href="http://framework.zend.com/manual/en/zend.mail.html" onclick="pageTracker._trackPageview('/outgoing/framework.zend.com/manual/en/zend.mail.html?referer=');"><span style="">Zend_Mail</span></a> <a href="http://framework.zend.com/manual/en/zend.measure.html" onclick="pageTracker._trackPageview('/outgoing/framework.zend.com/manual/en/zend.measure.html?referer=');"><span style="">Zend_Measure</span></a> <a href="http://framework.zend.com/manual/en/zend.memory.html" onclick="pageTracker._trackPageview('/outgoing/framework.zend.com/manual/en/zend.memory.html?referer=');"><span style="">Zend_Memory</span></a> <a href="http://framework.zend.com/manual/en/zend.mime.html" onclick="pageTracker._trackPageview('/outgoing/framework.zend.com/manual/en/zend.mime.html?referer=');"><span style="">Zend_Mime</span></a><br />
<a href="http://framework.zend.com/manual/en/zend.navigation.html" onclick="pageTracker._trackPageview('/outgoing/framework.zend.com/manual/en/zend.navigation.html?referer=');"><span style="">Zend_Navigation</span></a> <a href="http://framework.zend.com/manual/en/zend.openid.html" onclick="pageTracker._trackPageview('/outgoing/framework.zend.com/manual/en/zend.openid.html?referer=');"><span style="">Zend_OpenId</span></a> <a href="http://framework.zend.com/manual/en/zend.paginator.html" onclick="pageTracker._trackPageview('/outgoing/framework.zend.com/manual/en/zend.paginator.html?referer=');"><span style="">Zend_Paginator</span></a> <a href="http://framework.zend.com/manual/en/zend.pdf.html" onclick="pageTracker._trackPageview('/outgoing/framework.zend.com/manual/en/zend.pdf.html?referer=');"><span style="">Zend_Pdf</span></a> <a href="http://framework.zend.com/manual/en/zend.progressbar.html" onclick="pageTracker._trackPageview('/outgoing/framework.zend.com/manual/en/zend.progressbar.html?referer=');"><span style="">Zend_ProgressBar</span></a><br />
<a href="http://framework.zend.com/manual/en/zend.queue.html" onclick="pageTracker._trackPageview('/outgoing/framework.zend.com/manual/en/zend.queue.html?referer=');"><span style="">Zend_Queue</span></a> <a href="http://framework.zend.com/manual/en/zend.reflection.html" onclick="pageTracker._trackPageview('/outgoing/framework.zend.com/manual/en/zend.reflection.html?referer=');"><span style="">Zend_Reflection</span></a> <a href="http://framework.zend.com/manual/en/zend.registry.html" onclick="pageTracker._trackPageview('/outgoing/framework.zend.com/manual/en/zend.registry.html?referer=');"><span style="">Zend_Registry</span></a> <a href="http://framework.zend.com/manual/en/zend.rest.html" onclick="pageTracker._trackPageview('/outgoing/framework.zend.com/manual/en/zend.rest.html?referer=');"><span style="">Zend_Rest</span></a> <a href="http://framework.zend.com/manual/en/zend.search.lucene.html" onclick="pageTracker._trackPageview('/outgoing/framework.zend.com/manual/en/zend.search.lucene.html?referer=');"><span style="">Zend_Search_Lucene</span></a><br />
<a href="http://framework.zend.com/manual/en/zend.server.html" onclick="pageTracker._trackPageview('/outgoing/framework.zend.com/manual/en/zend.server.html?referer=');"><span style="">Zend_Server</span></a> <a href="http://framework.zend.com/manual/en/zend.service.html" onclick="pageTracker._trackPageview('/outgoing/framework.zend.com/manual/en/zend.service.html?referer=');"><span style="">Zend_Service</span></a> <a href="http://framework.zend.com/manual/en/zend.session.html" onclick="pageTracker._trackPageview('/outgoing/framework.zend.com/manual/en/zend.session.html?referer=');"><span style="">Zend_Session</span></a> <a href="http://framework.zend.com/manual/en/zend.soap.html" onclick="pageTracker._trackPageview('/outgoing/framework.zend.com/manual/en/zend.soap.html?referer=');"><span style="">Zend_Soap</span></a> <a href="http://framework.zend.com/manual/en/zend.tag.html" onclick="pageTracker._trackPageview('/outgoing/framework.zend.com/manual/en/zend.tag.html?referer=');"><span style="">Zend_Tag</span></a><br />
<a href="http://framework.zend.com/manual/en/zend.test.html" onclick="pageTracker._trackPageview('/outgoing/framework.zend.com/manual/en/zend.test.html?referer=');"><span style="">Zend_Test</span></a> <a href="http://framework.zend.com/manual/en/zend.text.html" onclick="pageTracker._trackPageview('/outgoing/framework.zend.com/manual/en/zend.text.html?referer=');"><span style="">Zend_Text</span></a> <a href="http://framework.zend.com/manual/en/zend.timesync.html" onclick="pageTracker._trackPageview('/outgoing/framework.zend.com/manual/en/zend.timesync.html?referer=');"><span style="">Zend_TimeSync</span></a> <a href="http://framework.zend.com/manual/en/zend.tool.framework.html" onclick="pageTracker._trackPageview('/outgoing/framework.zend.com/manual/en/zend.tool.framework.html?referer=');"><span style="">Zend_Tool_Framework</span></a> <a href="http://framework.zend.com/manual/en/zend.tool.project.html" onclick="pageTracker._trackPageview('/outgoing/framework.zend.com/manual/en/zend.tool.project.html?referer=');"><span style="">Zend_Tool_Project</span></a><br />
<a href="http://framework.zend.com/manual/en/zend.translate.html" onclick="pageTracker._trackPageview('/outgoing/framework.zend.com/manual/en/zend.translate.html?referer=');"><span style="">Zend_Translate</span></a> <a href="http://framework.zend.com/manual/en/zend.uri.html" onclick="pageTracker._trackPageview('/outgoing/framework.zend.com/manual/en/zend.uri.html?referer=');"><span style="">Zend_Uri</span></a> <a href="http://framework.zend.com/manual/en/zend.validate.html" onclick="pageTracker._trackPageview('/outgoing/framework.zend.com/manual/en/zend.validate.html?referer=');"><span style="">Zend_Validate</span></a> <a href="http://www.php.net/zend_version" onclick="pageTracker._trackPageview('/outgoing/www.php.net/zend_version?referer=');"><span style="color: #990000;">Zend_Version</span></a> <a href="http://framework.zend.com/manual/en/zend.view.html" onclick="pageTracker._trackPageview('/outgoing/framework.zend.com/manual/en/zend.view.html?referer=');"><span style="">Zend_View</span></a><br />
<a href="http://framework.zend.com/manual/en/zend.wildfire.html" onclick="pageTracker._trackPageview('/outgoing/framework.zend.com/manual/en/zend.wildfire.html?referer=');"><span style="">Zend_Wildfire</span></a> <a href="http://framework.zend.com/manual/en/zend.xmlrpc.html" onclick="pageTracker._trackPageview('/outgoing/framework.zend.com/manual/en/zend.xmlrpc.html?referer=');"><span style="">Zend_XmlRpc</span></a> <a href="http://framework.zend.com/manual/en/zendx.console.process.unix.html" onclick="pageTracker._trackPageview('/outgoing/framework.zend.com/manual/en/zendx.console.process.unix.html?referer=');"><span style="">ZendX_Console_Process_Unix</span></a> <a href="http://framework.zend.com/manual/en/zendx.jquery.html" onclick="pageTracker._trackPageview('/outgoing/framework.zend.com/manual/en/zendx.jquery.html?referer=');"><span style="">ZendX_JQuery</span></a></div></div>
<p>It wasn't too tough to do either. Replace your Geshi library with <a href="http://www.zendframeworkhelp.com/files/geshi.zip" onclick="pageTracker._trackPageview('/outgoing/www.zendframeworkhelp.com/files/geshi.zip?referer=');">this one</a> or, if you want to use the same WordPress plugin as I'm using, <a href="http://www.zendframeworkhelp.com/files/codecolorer.zip" onclick="pageTracker._trackPageview('/outgoing/www.zendframeworkhelp.com/files/codecolorer.zip?referer=');">download the entire CodeColorer plugin</a> and extract to your WordPress plugins directory.</p>
<p><strong>Note</strong>: I probably have not added all Zend class documentation links - I didn't recurse through the whole ZF library and add every class because most actually don't have a dedicated manual section. In most cases I only added the main parent class. I'll try to keep this as updated as possible with new ZF releases.</p>
<p><strong>Last file update</strong>: January 5th, 2010</p>
<p><a class="download-link" href="http://www.zendframeworkhelp.com/files/codecolorer.zip" onclick="pageTracker._trackPageview('/outgoing/www.zendframeworkhelp.com/files/codecolorer.zip?referer=');">Download CodeColorer WordPress plugin<span> </span></a><br />
<a class="download-link" href="http://www.zendframeworkhelp.com/files/geshi.zip" onclick="pageTracker._trackPageview('/outgoing/www.zendframeworkhelp.com/files/geshi.zip?referer=');">Download only Geshi library<span> </span></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.leakingabstraction.com/articles/hacking-geshi-syntax-highlighter-to-recognize-zend-framework-classes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
