<?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>@TheKeyboard &#187; CakePHP</title>
	<atom:link href="http://www.littlehart.net/atthekeyboard/tag/cakephp/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.littlehart.net/atthekeyboard</link>
	<description>Facebook should&#039;ve be written in unicornSchemaLang, because everyone *knows* that PHP is no good for anything, right?</description>
	<lastBuildDate>Thu, 29 Jul 2010 20:05:27 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Expand your programming mind:  filters in Lithium</title>
		<link>http://www.littlehart.net/atthekeyboard/2010/03/16/expand-your-programming-mind-filters-in-lithium/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=rss</link>
		<comments>http://www.littlehart.net/atthekeyboard/2010/03/16/expand-your-programming-mind-filters-in-lithium/#comments</comments>
		<pubDate>Tue, 16 Mar 2010 15:27:17 +0000</pubDate>
		<dc:creator>Chris Hartjes</dc:creator>
				<category><![CDATA[Chris' Brain]]></category>
		<category><![CDATA[aspect-oriented programming]]></category>
		<category><![CDATA[behaviors]]></category>
		<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[callbacks]]></category>
		<category><![CDATA[closures]]></category>
		<category><![CDATA[Django]]></category>
		<category><![CDATA[filters]]></category>
		<category><![CDATA[li3]]></category>
		<category><![CDATA[namespaces]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.littlehart.net/atthekeyboard/?p=699</guid>
		<description><![CDATA[Out of the ashes of a severe personality clash in an open source PHP web application framework project rose a new framework proclaiming that it simply sucks less than all the others. Lithium, otherwise known as li3, is the latest PHP application framework to come onto the scene. I know what you&#8217;re saying. *Yawn*. As [...]]]></description>
			<content:encoded><![CDATA[<p>Out of the ashes of a severe personality clash in an <a href="http://cakephp.org">open source PHP web application framework project</a> rose a new framework proclaiming that it <a href="http://rad-dev.org/lithium/wiki">simply sucks less than all the others</a>.  Lithium, otherwise known as li3, is the latest PHP application framework to come onto the scene.  I know what you&#8217;re saying.  *Yawn*.
</p>
<p>
As far as I can tell, Lithium is trying it&#8217;s hardest to be fast, lightweight, and use all the features that PHP 5.3 has to offer.  I am unable to use it at work for a variety of reasons (not stable, required PHP 5.3 only, <a href="http://twitter.com/nateabele">Nate</a> is always picking on me via IM) but I am more interested in the ideas that are coming out of it.
</p>
<p>
It is using all the newest hawtness in the PHP world:  namespaces, closures, Phar, late static binding.  I could go on, but probably most of these things mean nothing to you until you actually need them.  In the framework world, namespaces are a big deal, an essential tool to avoiding collisions with 3rd party code you might want to integrate into your project.  Closures are very familiar to those who&#8217;ve done work with Ruby or Javascript.  Phar allows for some unarchiving on the fly of code, even potentially distributing your application as an archive that can be run.  Late static binding is something I&#8217;m trying to comes to grips with, as I have either never come across a need for it or never realized that I did and have implemented a workaround for it not realizing there is a simpler solution.
</p>
<p>
None of these are what I want to talk about.  I want to talk about something that I feel is a very underrated part of Lithium, the ability to define filters.  This is a concept that you find in <a href="http://en.wikipedia.org/wiki/Aspect-oriented_programming">Aspect-oriented programming</a>, and one that I imagine most programmers have never considered.  Here&#8217;s why I think it&#8217;s a big deal.
</p>
<p>
Most frameworks are designed around an OOP paradigm.  Yes, some mix them together (I&#8217;m looking at *you* CodeIgniter), but by and large you get the job done by extending on a base model / controller / helper / whatever to create new functionality.  Sometimes this is not avoidable.  But what AOP says is that there is another way, a way that Lithium has adopted as well.
</p>
<p>
Hence the creation of &#8220;filters&#8221;.  As far as I can tell (and I&#8217;m sure I will be jumped upon if I am wrong) the purpose of filters in Lithium is to allow you to add functionality without extending the class itself.  When I saw that I immediately understood why that is so awesome.
</p>
<p>
The idea of callbacks is also very similar:  if X happens, run code Y.  A staple of jQuery, Rails and probably other projects I have forgotten to mention.  The idea is still the same though.  In Garrett Woodworth&#8217;s <a href="http://www.slideshare.net/gwoo/li3-ocphp">presentation about Lithium to the Orange County PHP Users Group</a> he goes  over some solid examples of filters including:</p>
<ul>
<li>automatic use of the <a href="http://mirror.facebook.net/facebook/xhprof/doc.html">XHProf</a> for code profiling</li>
<li>automatic setting of parameters upon saving a pasted bit of code</li>
</ul>
<p>It&#8217;s also been used to <a href="http://misja.posterous.com/playing-with-lithium">automatically change string record ID&#8217;s into a MongoDB ID</a> and <a href="http://latestatic.com/integration-testing-or-how-i-learned-to-stop">graceful failing of an integration test suite when an error occurs</a>.
</p>
<p>
These filters remind me of behaviors in Rails (and in CakePHP as well) and makes me wonder if signals are the same thing in the Django world.  All in all, this looks to me to be a better way to extend functionality than actually overriding existing methods or hacking at something deep inside a class.  Figure out what functionality you want, figure out where it needs to be called, and add your filter.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.littlehart.net/atthekeyboard/2010/03/16/expand-your-programming-mind-filters-in-lithium/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>What Thrashed Around In Chris&#8217; Brain This Past Weekend</title>
		<link>http://www.littlehart.net/atthekeyboard/2009/11/23/what-thrashed-around-in-chris-brain-this-past-weekend/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=rss</link>
		<comments>http://www.littlehart.net/atthekeyboard/2009/11/23/what-thrashed-around-in-chris-brain-this-past-weekend/#comments</comments>
		<pubDate>Tue, 24 Nov 2009 02:12:49 +0000</pubDate>
		<dc:creator>Chris Hartjes</dc:creator>
				<category><![CDATA[Chris' Brain]]></category>
		<category><![CDATA[blog experiment]]></category>
		<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[codeigniter]]></category>
		<category><![CDATA[Django]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[Node.js]]></category>
		<category><![CDATA[vim]]></category>

		<guid isPermaLink="false">http://www.littlehart.net/atthekeyboard/?p=606</guid>
		<description><![CDATA[(The blog experiment continues: 1 post every weekday in November and I think I only skipped one, but made up for it with a Saturday post) Node.js is something I want to use, but I do not know what for For those who don&#8217;t know, Node is a &#8220;toolkit for writing extremely high performance non-blocking [...]]]></description>
			<content:encoded><![CDATA[<p>(The blog experiment continues: 1 post every weekday in November and I think I only skipped one, but made up for it with a Saturday post)</p>
<p>
<i>Node.js is something I want to use, but I do not know what for</i><br />
For those who don&#8217;t know, <a href="http://nodejs.org/">Node</a> is a &#8220;toolkit for writing extremely high performance non-blocking event driven network servers in JavaScript&#8221;.  In other words, it&#8217;s for writing server-side Javascript with an emphasis on providing concurrency.  Damn you Tim Bray, I cannot avoid seeing concurrency everywhere since you started your <a href="http://www.tbray.org/ongoing/When/200x/2009/09/27/Concur-dot-next">Concur.next</a> series on your blog.  It fascinates me, and I don&#8217;t even do any kind of work where I need to worry about concurrency.  Not yet anyway.
</p>
<p>
Simon Wilson (someone I follow from the Django community) has a great article explaining why <a href="http://simonwillison.net/2009/Nov/23/node/">Node.js is genuinely exciting</a> to him, and my old CakePHP landsmann Felix shows <a href="http://debuggable.com/posts/streaming-file-uploads-with-node-js:4ac094b2-b6c8-4a7f-bd07-28accbdd56cb">how to handling streaming file uploads in node.js</a>.  Like so many new technologies, Node.js starts out as a solution looking for a problem but as I become more familiar with concurrency it all becomes a little clearer.
</p>
<p>
<i>While <a href='http://www.vim/org">Vim</a> is awesome, don&#8217;t put up with any crap from it</i><br />
I had been experiencing a problem with Vim.  Well, two problems.  The first big one was weird behaviour involving the <a href="http://www.vim.org/scripts/script.php?script_id=1849">AutoClose</a> plugin.  It would spit out brackets and quotes at the weirdest time, and I found myself doing a lot of unnecessary keystrokes (and toggling in and out of insert mode) to get things done.  So I deleted it.  Enough of that crap.  Same goes with my attempts to use the <a href="http://www.vim.org/scripts/script.php?script_id=69">Project plugin</a>.  I just could not get it to work properly.  DELETED.
</p>
<p>
Vim&#8217;s ability to be ultracustomizable ALSO makes it easy to dump stuff when you no longer what to use it.  Heck, I even see some stuff in my .vimrc that I am not using any more.  Mappings I did to accomplish some specific tasks.  Those were deleted too.
</p>
<p>
<i>Understanding the concept of callbacks opens your mind to all sorts of possibilities</i><br />
While callbacks are related to my use of Javascript (jQuery uses them to great success) I also find myself digging into the <a href="http://docs.djangoproject.com/en/dev/topics/signals/">documentation in Django on signals</a>, which are callbacks by another name:  functionality that is executed when certain events happen.</p>
<p>Django uses them all over the place, and CakePHP uses them as well.  When I look at the CodeIgniter code that powers <a href="http://www.sportso.com">Sportso</a>, I often ruminate about what programming techniques or design patterns could help me reduce the amount of code that has actually been written.  CodeIgniter doesn&#8217;t really support callbacks except in the form of allowing you to define custom functions for validation purposes.  It&#8217;s a start I get.  I wonder what the code would look like if I could define more code that is triggered when specific events happen?  Any time I find myself typing the same block of code over and over again, it is only natural that I seek to reduce how often I need to do it.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.littlehart.net/atthekeyboard/2009/11/23/what-thrashed-around-in-chris-brain-this-past-weekend/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>New Site for &#8220;Refactoring Legacy Applications using CakePHP&#8221;</title>
		<link>http://www.littlehart.net/atthekeyboard/2009/10/27/new-site-for-refactoring-legacy-applications-using-cakephp/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=rss</link>
		<comments>http://www.littlehart.net/atthekeyboard/2009/10/27/new-site-for-refactoring-legacy-applications-using-cakephp/#comments</comments>
		<pubDate>Tue, 27 Oct 2009 15:17:05 +0000</pubDate>
		<dc:creator>Chris Hartjes</dc:creator>
				<category><![CDATA[Chris' Brain]]></category>
		<category><![CDATA[book]]></category>
		<category><![CDATA[CakePHP]]></category>

		<guid isPermaLink="false">http://www.littlehart.net/atthekeyboard/?p=555</guid>
		<description><![CDATA[While looking around for conferences to speak at that were within a decent drive of my home, I managed to come into contact with Jason Gilmore, who also sells PHP books via EasyPHPWebsites. He saw that I had written this book and offered to put it up for sale via his site. As a result, [...]]]></description>
			<content:encoded><![CDATA[<p>
While looking around for conferences to speak at that were within a decent drive of my home, I managed to come into contact with <a href="http://twitter.com/wjgilmore">Jason Gilmore</a>, who also sells PHP books via <a href="http://www.easyphpwebsites.com/">EasyPHPWebsites</a>.  He saw that I had written this book and offered to put it up for sale via his site.  As a result, the price of the book has gone up by $3 to handle some of the new costs, but I&#8217;m much happier with the marketing effort that will be accompanying the book.   Jason makes his living doing this sort of thing, so I&#8217;m happy to have a mentor for this process.  I have plans for future books, some of them not even in PHP. <img src='http://www.littlehart.net/atthekeyboard/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />
</p>
<p>
Bundled with the PDF will be access to some PHP-related screencasts.  Unfortunately I will not be able to offer videos to existing customers, only for new purchasers of the book.
</p>
<p>
The cost of the print-on-demand copy hasn&#8217;t changed, and sometime later today I will be uploading a version of the book with the hot new cover.  I don&#8217;t think the price will be changing at all.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.littlehart.net/atthekeyboard/2009/10/27/new-site-for-refactoring-legacy-applications-using-cakephp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A Simple CouchDB Datasource</title>
		<link>http://www.littlehart.net/atthekeyboard/2009/06/05/a-simple-couchdb-datasource/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=rss</link>
		<comments>http://www.littlehart.net/atthekeyboard/2009/06/05/a-simple-couchdb-datasource/#comments</comments>
		<pubDate>Fri, 05 Jun 2009 19:55:23 +0000</pubDate>
		<dc:creator>Chris Hartjes</dc:creator>
				<category><![CDATA[Chris' Brain]]></category>
		<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[CouchDB]]></category>
		<category><![CDATA[datasource]]></category>

		<guid isPermaLink="false">http://www.littlehart.net/atthekeyboard/?p=483</guid>
		<description><![CDATA[Yes, my waffling continues. But this time it is NOT with respect to what editor to use, as the one true editor has been configured in such a way to make my life easier. I have a personal project that I have been waffling about building in Python (first as a Django app, now maybe [...]]]></description>
			<content:encoded><![CDATA[<p>
Yes, my waffling continues.  But this time it is NOT with respect to what editor to use, as <a href="http://www.vim.org">the one true editor</a> has been configured in such a way to make my life easier.  I have a personal project that I have been waffling about building in Python (first as a Django app, now maybe as a web2py app) or in CakePHP, since I would probably be most productive building out something quickly using it.
</p>
<p>
Since I'm in a CakePHP phase right now, I decided to start building out some of the components I would need to make the side project work.  One of those components is the use of <a href="http://couchdb.apache.org">CouchDB</a> as the database.  Since non-relational databases are all the hawtness right now (and <a href="http://twitter.com/janl">Jan Lehnardt</a> is such an awesome guy) I decided the best way to learn it's use is to store search results by users to my site (no hints on what I'm doing).  I figured the best way to do this was to create a CouchDB datasource, add it to my application, and then create models that would use the datasource.
</p>
<p>
While I suggest that you visit the CouchDB website for more info on what it is and how to use it, here's a quick summary:  CouchDB is a non-relational datastore that you communicate with using views written in Javascript, and it returns any records that match your view as JSON-formatted data.  Very simple when you think of it, but also very powerful.
</p>
<p>
I must emphasize that the code is very raw and not fully tested.  Written using PHP 5.2.9 and Cake 1.2.bleeding.edge. First, the data source:</p>
<div class="igBar"><span id="lphp-6"><a href="#" onclick="javascript:showPlainTxt('php-6'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-6">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">&lt;?php</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">/**</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;"> * Datasource for connecting to CouchDB</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;"> *</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;"> * @author Chris Hartjes</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;"> */</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">class</span> CouchDbSource extends DataSource <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; public <span style="color:#0000FF;">$description</span> = <span style="color:#FF0000;">'CouchDB Data Source'</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; public <span style="color:#0000FF;">$host</span> = <span style="color:#FF0000;">'localhost'</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; public <span style="color:#0000FF;">$port</span> = <span style="color:#CC66CC;color:#800000;">5984</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; public <span style="color:#0000FF;">$error_number</span> = <span style="color:#000000; font-weight:bold;">null</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; public <span style="color:#0000FF;">$error_message</span> = <span style="color:#000000; font-weight:bold;">null</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; public <span style="color:#0000FF;">$headers</span> = <span style="color:#000000; font-weight:bold;">null</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; public <span style="color:#0000FF;">$body</span> = <span style="color:#000000; font-weight:bold;">null</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; public <span style="color:#000000; font-weight:bold;">function</span> __construct<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$config</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; parent::__construct<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$config</span><span style="color:#006600; font-weight:bold;">&#41;</span>;&nbsp; &nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">if</span> <span style="color:#006600; font-weight:bold;">&#40;</span>!<a href="http://www.php.net/empty"><span style="color:#000066;">empty</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">config</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'host'</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">host</span> = <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">config</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'host'</span><span style="color:#006600; font-weight:bold;">&#93;</span>;&nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">if</span> <span style="color:#006600; font-weight:bold;">&#40;</span>!<a href="http://www.php.net/empty"><span style="color:#000066;">empty</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">config</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'port'</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">post</span> = <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">config</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'port'</span><span style="color:#006600; font-weight:bold;">&#93;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; public <span style="color:#000000; font-weight:bold;">function</span> fullTableName<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">return</span> <span style="color:#000000; font-weight:bold;">false</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#008000;">/**</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">&nbsp; &nbsp;&nbsp; * Method that sends data to the CouchDB server</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">&nbsp; &nbsp;&nbsp; *</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">&nbsp; &nbsp;&nbsp; * @param $method string GET, POST, PUT or DELETE</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">&nbsp; &nbsp;&nbsp; * @param $url string URL you are trying to send to</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">&nbsp; &nbsp;&nbsp; * @param $post_data string optional data to be posted</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">&nbsp; &nbsp;&nbsp; * @return string</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">&nbsp; &nbsp;&nbsp; */</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; public <span style="color:#000000; font-weight:bold;">function</span> send<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$method</span>, <span style="color:#0000FF;">$url</span>, <span style="color:#0000FF;">$post_data</span> = <span style="color:#000000; font-weight:bold;">NULL</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$s</span> = <a href="http://www.php.net/fsockopen"><span style="color:#000066;">fsockopen</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">host</span>, <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">port</span>, <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">error_number</span>, <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">error_message</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">if</span> <span style="color:#006600; font-weight:bold;">&#40;</span>!<span style="color:#0000FF;">$s</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">return</span> <span style="color:#000000; font-weight:bold;">false</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$request</span> = <span style="color:#FF0000;">"{$method} {$url} HTTP/1.0<span style="color:#000099; font-weight:bold;">\r</span><span style="color:#000099; font-weight:bold;">\n</span>Host: {$this-&gt;host}<span style="color:#000099; font-weight:bold;">\r</span><span style="color:#000099; font-weight:bold;">\n</span>"</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">if</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$post_data</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$request</span> .= <span style="color:#FF0000;">"Content-Length: "</span> . <a href="http://www.php.net/strlen"><span style="color:#000066;">strlen</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$post_data</span><span style="color:#006600; font-weight:bold;">&#41;</span> . <span style="color:#FF0000;">"<span style="color:#000099; font-weight:bold;">\r</span><span style="color:#000099; font-weight:bold;">\n</span><span style="color:#000099; font-weight:bold;">\r</span><span style="color:#000099; font-weight:bold;">\n</span>"</span>;&nbsp; &nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$request</span> .= <span style="color:#FF0000;">"{$post_data}<span style="color:#000099; font-weight:bold;">\r</span><span style="color:#000099; font-weight:bold;">\n</span>"</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span> <span style="color:#616100;">else</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$request</span> .= <span style="color:#FF0000;">"<span style="color:#000099; font-weight:bold;">\r</span><span style="color:#000099; font-weight:bold;">\n</span>"</span>;&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/fwrite"><span style="color:#000066;">fwrite</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$s</span>, <span style="color:#0000FF;">$request</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$response</span> = <span style="color:#FF0000;">""</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">while</span> <span style="color:#006600; font-weight:bold;">&#40;</span>!<a href="http://www.php.net/feof"><span style="color:#000066;">feof</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$s</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$response</span> .= <a href="http://www.php.net/fgets"><span style="color:#000066;">fgets</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$s</span><span style="color:#006600; font-weight:bold;">&#41;</span>;&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/list"><span style="color:#000066;">list</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">headers</span>, <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">body</span><span style="color:#006600; font-weight:bold;">&#41;</span> = <a href="http://www.php.net/explode"><span style="color:#000066;">explode</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">"<span style="color:#000099; font-weight:bold;">\r</span><span style="color:#000099; font-weight:bold;">\n</span><span style="color:#000099; font-weight:bold;">\r</span><span style="color:#000099; font-weight:bold;">\n</span>"</span>, <span style="color:#0000FF;">$response</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">return</span> <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">body</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">?&gt;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p>
I warned you that it was very simple.
</p>
<p>
So, if you want to use the datasource, the first thing to do is add an entry to your APP/config/database.php file with all the pertinent configuration info:</p>
<div class="igBar"><span id="lphp-7"><a href="#" onclick="javascript:showPlainTxt('php-7'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-7">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">&lt;?php</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">class</span> DATABASE_CONFIG <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#000000; font-weight:bold;">var</span> <span style="color:#0000FF;">$couchdb</span> = <a href="http://www.php.net/array"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#FF0000;">'datasource'</span> =&gt; <span style="color:#FF0000;">'couchdb'</span>,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#FF0000;">'host'</span> =&gt; <span style="color:#FF0000;">'localhost'</span>,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#FF0000;">'port'</span> =&gt; <span style="color:#CC66CC;color:#800000;">5984</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">?&gt;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p>CouchDB by default runs on port 5984, but like most flexible applications it lets you change that port if you need to.  That's really all the configuration info you'll need.
</p>
<p>
So next up is configuring a model to use it. </p>
<div class="igBar"><span id="lphp-8"><a href="#" onclick="javascript:showPlainTxt('php-8'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-8">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">&lt;?php</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">class</span> Search extends AppModel <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; public <span style="color:#0000FF;">$name</span> = <span style="color:#FF0000;">'Search'</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; public <span style="color:#0000FF;">$useDbConfig</span> = <span style="color:#FF0000;">'couchdb'</span>;&nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; public <span style="color:#0000FF;">$useTable</span> = <span style="color:#000000; font-weight:bold;">null</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; public <span style="color:#000000; font-weight:bold;">function</span> send<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$method</span>, <span style="color:#0000FF;">$url</span>, <span style="color:#0000FF;">$post_data</span> = <span style="color:#000000; font-weight:bold;">NULL</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">return</span> <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">getDataSource</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>-&gt;<span style="color:#006600;">send</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$method</span>, <span style="color:#0000FF;">$url</span>, <span style="color:#0000FF;">$post_data</span><span style="color:#006600; font-weight:bold;">&#41;</span>;&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">?&gt;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p>
Thanks to <a href="http://twitter.com/jperras">Joel Perras</a> for helping me dig through the CakePHP internals in order to figure out the best way to get my model to speak to the datasource.  And pointing out my stupid mistake that caused CakePHP's automodel magic to bite me in the ass.
</p>
<p>
So how do you actually use this thing.  Here's an example of asking CouchDB to give you a listing of all documents available on the server:</p>
<div class="igBar"><span id="lphp-9"><a href="#" onclick="javascript:showPlainTxt('php-9'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-9">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">APP/controllers/searches_controller.php</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">&lt;?php</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">class</span> SearchesController extends AppController <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; public <span style="color:#000000; font-weight:bold;">function</span> show_all<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">layout</span> = <span style="color:#FF0000;">'ajax'</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$response</span> = <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">Search</span>-&gt;<span style="color:#006600;">send</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'GET'</span>, <span style="color:#FF0000;">'/searches/_all_docs'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">set</span><span style="color:#006600; font-weight:bold;">&#40;</span><a href="http://www.php.net/compact"><span style="color:#000066;">compact</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'response'</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">?&gt;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">APP/views/searches/show_all.ctp</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">&lt;?</span>= <span style="color:#0000FF;">$response</span> <span style="color:#000000; font-weight:bold;">?&gt;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p>
</p>
<p>
In my case, the view spit out a nice string that looked like this:</p>
<div class="igBar"><span id="ljavascript-10"><a href="#" onclick="javascript:showPlainTxt('javascript-10'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">JAVASCRIPT:</span>
<div id="javascript-10">
<div class="javascript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#123;</span><span style="color: #3366CC;">"total_rows"</span>:<span style="color: #CC0000;color:#800000;">1</span>,<span style="color: #3366CC;">"offset"</span>:<span style="color: #CC0000;color:#800000;">0</span>,<span style="color: #3366CC;">"rows"</span>:<span style="color: #66cc66;">&#91;</span> <span style="color: #66cc66;">&#123;</span><span style="color: #3366CC;">"id"</span>:<span style="color: #3366CC;">"e2ffaae4df81b66c3d8386b75be71aa3"</span>,<span style="color: #3366CC;">"key"</span>:<span style="color: #3366CC;">"e2ffaae4df81b66c3d8386b75be71aa3"</span>,<span style="color: #3366CC;">"value"</span>:<span style="color: #66cc66;">&#123;</span><span style="color: #3366CC;">"rev"</span>:<span style="color: #3366CC;">"1-71594714"</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p>
</p>
<p>
So there you have it.  If you want to do more work with this datasource, I suggest you take a look at <a href="http://wiki.apache.org/couchdb/Getting_started_with_PHP">this link on the CouchDB wiki</a> about using PHP with CakePHP.   It could use some work to add in convenience methods for adding, deleting and finding specific records but it's a good start I think.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.littlehart.net/atthekeyboard/2009/06/05/a-simple-couchdb-datasource/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Book Now Available On Amazon!</title>
		<link>http://www.littlehart.net/atthekeyboard/2009/05/26/book-now-available-on-amazon/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=rss</link>
		<comments>http://www.littlehart.net/atthekeyboard/2009/05/26/book-now-available-on-amazon/#comments</comments>
		<pubDate>Wed, 27 May 2009 01:55:53 +0000</pubDate>
		<dc:creator>Chris Hartjes</dc:creator>
				<category><![CDATA[Chris' Brain]]></category>
		<category><![CDATA[Amazon]]></category>
		<category><![CDATA[book]]></category>
		<category><![CDATA[CakePHP]]></category>

		<guid isPermaLink="false">http://www.littlehart.net/atthekeyboard/?p=478</guid>
		<description><![CDATA[I received an email this evening that you can now purchase my book through Amazon.com's Marketplace! Awesome news. Check out the link http://tinyurl.com/p5o79u and be sure to add your feedback to the page if you've bought a copy. (Edit: hrm, link doesn't show up on front page but shows up if you click on the [...]]]></description>
			<content:encoded><![CDATA[<p>I received an email this evening that you can now purchase my book through Amazon.com's Marketplace!  Awesome news. Check out the link <a href="http://tinyurl.com/p5o79u">http://tinyurl.com/p5o79u</a> and be sure to add your feedback to the page if you've bought a copy.</p>
<p>(Edit: hrm, link doesn't show up on front page but shows up if you click on the link to this posting...)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.littlehart.net/atthekeyboard/2009/05/26/book-now-available-on-amazon/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Laziness vs. Efficiency</title>
		<link>http://www.littlehart.net/atthekeyboard/2009/05/21/laziness-vs-efficiency/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=rss</link>
		<comments>http://www.littlehart.net/atthekeyboard/2009/05/21/laziness-vs-efficiency/#comments</comments>
		<pubDate>Thu, 21 May 2009 15:21:00 +0000</pubDate>
		<dc:creator>Chris Hartjes</dc:creator>
				<category><![CDATA[Chris' Brain]]></category>
		<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[efficiency]]></category>
		<category><![CDATA[frameworks]]></category>
		<category><![CDATA[lazy developers]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://www.littlehart.net/atthekeyboard/?p=476</guid>
		<description><![CDATA[Joel Moss (a fellow member of the CakePHP community) has been acting like a bit of a Rails (and Ruby) fanboi as of late. He's doing a series of blog posts proclaiming his love for Ruby. Personally, I loved Rails when I first encountered it. Played around with it. Wrote a web site for my [...]]]></description>
			<content:encoded><![CDATA[<p>Joel Moss (a fellow member of the CakePHP community) has been acting like a bit of a Rails (and Ruby) fanboi as of late.  He's doing a series of blog posts proclaiming his <a href="http://developingwithstyle.com/2009/05/20/10-reasons-why-ruby-is-better-than-php-reason-1/">love for Ruby</a>.  Personally, I loved Rails when I first encountered it.  Played around with it.  Wrote a web site for my simulation baseball league in it.  Then started disliking *some* of the people in the community and are now pretty much ambivalent about Ruby and Rails in general.  Great tool, not for me.  Python seems to be a better fit for me at least.</p>
<p>
I think a lot of what he says is nonsense and can be summarized with "I don't like PHP's syntax."  Hell, I don't even like it myself.  PHP's big problem has been consistency with parameter order and a less-than-stellar object implementation.  Yes, things have improved in terms of OOP (closures and traits!) but PHP clings hard to it's procedural roots and that is not necessarily a bad thing.  Slamming PHP for it's OO implementation is like picking at a scab so it never goes away.  Pointless.  "PHP sucks because of bad syntax" is an argument I'd expect from my 9 year-old daughter, not a good programmer like Joel.  Kind of disappointing.  Never mind all the awesome built-in functions or wealth of high-quality third-party libraries out there for PHP.  Sure, those things exist for Ruby too but often you only have one or two choices.  PHP is absolutely rich in choices of third-party libraries.  Sure, a lot of them are not top quality but it never takes long to figure that out.  Okay, I'm drifting.  On to the rest of my point.
</p>
<p>
 I think where Joel starts to go off the rails was a follow-up in Twitter that said "Hands up if you're a lazy developer. [I proudly hold both my hands up high in the sky] Laziness makes me a better coder http://bit.ly/MKFQe".   Once and for all, we need to stamp out the "laziness makes me a better coder" meme that is picking up steam.  There is a HUGE difference between laziness defined as "I want to write less code" and laziness defined as "I don't want to have to figure shit out.".  The first one is called efficiency, not laziness.  The second one is the type of trait that a programmer should be ashamed to have.
</p>
<p>
I realize now that reliance on the use of frameworks for your applications is the type of laziness that is straying from efficiency to pure laziness.  Before you get all riled up, hear (read?) me out.  When you use a framework, you are accepting that it will be abstracting a lot of functionality away.  Functionality that you might not even understand correctly.  Which is great for quickly building something, but bad when you run into an error being generated by the framework itself.  Or behaviour that is unexpected. I like to call this "fighting against the conventions", and I believe that is the #1 reason why people end up not using a particular framework.  They cannot or are unwilling to follow the conventions and as a result, nothing will work.</p>
<p>
So, if you use a framework all the time, you might find that certain skills or bits of knowledge start to erode.  Use an ORM all the time?  You forget how to make finely tuned SQL queries.  Rely on built-in form validation?  You start to forget what POST requests look like.  Use the Ajax helper that comes with the framework?  You forget how to make tight, customized Javascript code.  I think you're starting to get the point.
</p>
<p>
Joel is 100% correct when he talks about that there are features in Ruby that allow you to be more EFFICIENT with your code than in PHP.  That is not laziness.  Usually when a developer calls themselves lazy, it is a self-deprecating statement.  I have called myself "lazy" because I strive to write as little code as possible to accomplish a task.  That's not laziness, that's efficiency.
</p>
<p>
The use of the term "laziness in terms of coding" is just a bad one to use.  Use the proper term, which is "efficiency in terms of coding".  "Laziness in terms of coding" is cut-and-pasting code all over the place, or blind use of code examples you find on the web without understanding what they really do.
</p>
<p>
Joel, I'm happy that you are loving Ruby.  Python gives me the same fuzzy glow on those occasions when I play around with it.  But please put things in the proper prospective.  To paraphrase the Princess Bride:  "You keep using that word. I do not think it means what you think it means."</p>
]]></content:encoded>
			<wfw:commentRss>http://www.littlehart.net/atthekeyboard/2009/05/21/laziness-vs-efficiency/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>My Next Book</title>
		<link>http://www.littlehart.net/atthekeyboard/2009/05/14/my-next-book/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=rss</link>
		<comments>http://www.littlehart.net/atthekeyboard/2009/05/14/my-next-book/#comments</comments>
		<pubDate>Thu, 14 May 2009 18:23:43 +0000</pubDate>
		<dc:creator>Chris Hartjes</dc:creator>
				<category><![CDATA[Chris' Brain]]></category>
		<category><![CDATA[book]]></category>
		<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[TDD]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://www.littlehart.net/atthekeyboard/?p=474</guid>
		<description><![CDATA[Okay, so since the first book has been a pretty good success for me, I've been thinking about writing a second book. Will be the same format: PDF, under 100 pages, selling for between $10 and $20. So that got me to thinking "what topic could I go on and on about like an idiot [...]]]></description>
			<content:encoded><![CDATA[<p>Okay, so since the first book has been a pretty good success for me, I've been thinking about writing a second book.  Will be the same format:  PDF, under 100 pages, selling for between $10 and $20.  So that got me to thinking "what topic could I go on and on about like an idiot in regards to programming and CakePHP in general?"</p>
<p>
I've become a believer in Test Driven Development and TATFT practices (thanks to <a href="http://gilesbowkett.blogspot.com/2009/05/one-way-to-escape-cargo-cult.html">Giles Bowkett</a> for his blog posts espousing the concept.  So why not combine that with my knowledge (no jokes from Nate allowed) of CakePHP and produce another inexpensive book.  Thus, the seeds of "Test Driven Development Using CakePHP" have been planted in my mind.
</p>
<p>
Of course, the book will be made easier by the fact that I have a CakePHP project on the go at work where I am using TDD, so once again I will be producing a book with code examples and comments about what I was doing.  So, I am asking *you* what sort of things would you like to see in this book about TDD and CakePHP?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.littlehart.net/atthekeyboard/2009/05/14/my-next-book/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Chris&#8217; Brain &#8211; May 2009 Edition</title>
		<link>http://www.littlehart.net/atthekeyboard/2009/05/01/chris-brain-may-2009-edition/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=rss</link>
		<comments>http://www.littlehart.net/atthekeyboard/2009/05/01/chris-brain-may-2009-edition/#comments</comments>
		<pubDate>Fri, 01 May 2009 14:13:58 +0000</pubDate>
		<dc:creator>Chris Hartjes</dc:creator>
				<category><![CDATA[Chris' Brain]]></category>
		<category><![CDATA[book]]></category>
		<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[capistrano]]></category>
		<category><![CDATA[Deployment]]></category>
		<category><![CDATA[open source]]></category>

		<guid isPermaLink="false">http://www.littlehart.net/atthekeyboard/?p=466</guid>
		<description><![CDATA[Book Update For those not following along on Twitter, the first month of sales of my CakePHP book have been a success: 70 PDF's and 5 print-on-demand copies via Lulu.com. A big thanks to everyone who has purchased a copy. My next thought has been a book about doing Test Driven Development using CakePHP, but [...]]]></description>
			<content:encoded><![CDATA[<h2>Book Update</h2>
<p>
For those not following along on Twitter, the first month of sales of my <a href="http://littlehart.net/book">CakePHP book</a> have been a success:  70 PDF's and 5 print-on-demand copies via <a href="http://www.lulu.com/content/paperback-book/refactoring-legacy-applications-using-cakephp/6626981">Lulu.com</a>.  A big thanks to everyone who has purchased a copy.  My next thought has been a book about doing Test Driven Development using CakePHP, but perhaps that is just wishcasting.
</p>
<h2>Deployment Thoughts</h2>
<p>
At work I've been tweaking the deployment process for an <a href="http://www.sportsdb.org/sd/sportscaster">open source project</a> that talks to our infrastructure and came upon an interesting problem.  Like many projects, we have some configuration files that would be different from environment to environment (i.e. different database access credentials, paths to archived files) so we've chosen to instead create sample versions of those configuration files and include them in the  application when you either download it (as external clients of ours do) or update from SVN (like we do).
</p>
<p>
Since I like to use <a href="http://capify.org">Capistrano</a> to do deployment, I needed a way to make sure that the configuration files that are currently being used by the application get copied into the proper place.  Lucky for me, it was easy enough to add this in as a task in my Capfile:</p>
<div class="igBar"><span id="lruby-12"><a href="#" onclick="javascript:showPlainTxt('ruby-12'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">RUBY:</span>
<div id="ruby-12">
<div class="ruby">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000; font-style:italic;"># Do nothing (To restart apache, run 'cap deploy:apache:restart')</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; task :restart <span style="color:#9966CC; font-weight:bold;">do</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; run <span style="color:#996600;">"cp /var/www/settings/sportscaster/gateway/php/config.php #{deploy_to}/current/gateway/php"</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; run <span style="color:#996600;">"cp /var/www/settings/sportscaster/gateway/php_ci/config/gateway.config.php #{deploy_to}/current/gateway/php_ci/config"</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; run <span style="color:#996600;">"cp /var/www/settings/sportscaster/engine/_application/config/database.php #{deploy_to}/current/engine/_application/config"</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; run <span style="color:#996600;">"cp /var/www/settings/sportscaster/engine/_application/config/config.php #{deploy_to}/current/engine/_application/config"</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#9966CC; font-weight:bold;">end</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p>
As you can see, I've placed the configuration files in their own directory (off the web root I know, might make more sense to put them some place else but they can live there for now) and then simply copy them in place once I've deployed the latest code.  I'd be interested in seeing how other people handle this issue.
</p>
<h2>Getting paid to do open source work</h2>
<p>
I feel like I'm very fortunate to have an employer who (mostly for business reasons) has decided to make some of their projects open source so that others can use it without cost.  Sure, some of it is niche software to be sure (a web service that only works with our pay-to-use infrastructure) but still, d00d, I'm getting paid to write open source code!  We also have another project in the works, helping <a href="http://www.phpffl.com">these guys</a> create a newer, more generic version of their fantasy league management application that has hooks to allow users to pull in data from our own web services.  Sure, it's helping to drive our business but isn't that the point?  I create something that helps my company make money, and in exchange I get to share it with everyone else.  Sounds like a pretty good deal to me.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.littlehart.net/atthekeyboard/2009/05/01/chris-brain-may-2009-edition/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>CakePHP Application RFC Follow-Up</title>
		<link>http://www.littlehart.net/atthekeyboard/2009/04/23/cakephp-application-rfc-follow-up/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=rss</link>
		<comments>http://www.littlehart.net/atthekeyboard/2009/04/23/cakephp-application-rfc-follow-up/#comments</comments>
		<pubDate>Thu, 23 Apr 2009 15:52:29 +0000</pubDate>
		<dc:creator>Chris Hartjes</dc:creator>
				<category><![CDATA[Chris' Brain]]></category>
		<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[capistrano]]></category>
		<category><![CDATA[Chris not smart enough]]></category>
		<category><![CDATA[Deployment]]></category>
		<category><![CDATA[Phing]]></category>

		<guid isPermaLink="false">http://www.littlehart.net/atthekeyboard/?p=463</guid>
		<description><![CDATA[Holy moley, has it been almost a year since I blogged about a potential CakePHP deployment task. Since a few people have hit me up in Twitter and in the comments for that blog post, I thought I would share my progress on this task. To be blunt, I decided it was a waste of [...]]]></description>
			<content:encoded><![CDATA[<p>Holy moley, has it been almost a year since I <a href="http://www.littlehart.net/atthekeyboard/2008/05/16/cakephp-application-deployment-rfc">blogged about a potential CakePHP deployment task</a>.  Since a few people have hit me up in Twitter and in the comments for that blog post, I thought I would share my progress on this task.  To be blunt, I decided it was a waste of time to do it.</p>
<p>
Why?  Well, there plenty of options out there to help you with application deployment already.  I talked about many of them in the talk I gave at PHPQuebec back in March.  In the end, there is no reason to NOT use an existing tool to handle this other than you cannot (or in some cases will not) use one of these tools.  I picked <a href="http://www.capify.org">Capistrano</a> because:</p>
<ul>
<li>it is command-line based and therefore it's use could be easily automated in my development and production environments</li>
<li>deployment instructions are written in code, not XML.  Sure it's Ruby but don't be like that and sneer at me.  I work with XML all day long and know when it's good to use it and when it's not good to use it.  In my opinion, using it as a configuration file to tell you where to deploy your stuff is a misuse of it.  Why not do it in JSON then?  Hrm, there's an idea what will rattle around in my brain for a while.</li>
<li>it doesn't care what you are trying to deploy, which I think is such an understated feature of Capistrano that I tell it to EVERYONE who asks me about it.</li>
</ul>
<p>
Sure, being able to type 'cake deploy' would be nice for those people who are using Cake and have things setup completely according to the default configuration, but one little change and the whole thing might just blow up.  Capistrano and <a href="http://phing.info/trac/">Phing</a> are the two tools I would recommend to any PHP devs trying to work out automated deployment.
</p>
<p>Given the number of permutations that can be part of an install, I am not confident that 'cake deploy' would be up to the task.  When I think about all the stuff I have to deploy that is not just PHP code at work, I can't imagine making it all work in a CakePHP task.  That's not to say that someone smarter than me can't figure it out.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.littlehart.net/atthekeyboard/2009/04/23/cakephp-application-rfc-follow-up/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Lazyweb Questions &#8211; April 2009</title>
		<link>http://www.littlehart.net/atthekeyboard/2009/04/09/lazyweb-questions-april-2009/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=rss</link>
		<comments>http://www.littlehart.net/atthekeyboard/2009/04/09/lazyweb-questions-april-2009/#comments</comments>
		<pubDate>Thu, 09 Apr 2009 23:59:34 +0000</pubDate>
		<dc:creator>Chris Hartjes</dc:creator>
				<category><![CDATA[Chris' Brain]]></category>
		<category><![CDATA[book]]></category>
		<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[plugins]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[refactoring]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[vim]]></category>

		<guid isPermaLink="false">http://www.littlehart.net/atthekeyboard/?p=455</guid>
		<description><![CDATA[The book is doing quite well, thanks. 42 copies sold as I type this. I am going to give away one of my "Framework Apocalypse" t-shirts to one lucky random customer when I get to 100. Feedback has been great, so spread the word about the book! As Matt Curry pointed out in his review [...]]]></description>
			<content:encoded><![CDATA[<p>The book is doing quite well, thanks.  42 copies sold as I type this.  I am going to give away one of my "Framework Apocalypse" t-shirts to one lucky random customer when I get to 100.  Feedback has been great, so spread the word about the book!  As <a href="http://www.psuedocoder.com">Matt Curry</a> pointed out in his <a href="http://www.pseudocoder.com/archives/2009/04/08/review-refactoring-legacy-applications-using-cakephp/">review of my book</a>, don't let the name fool you.  It could've been subtitled "how to think like a CakePHP developer".
</p>
<p>
So, I have a few questions for the lazyweb (aka my awesome readers).  I'm hoping they can point me in the right direction.:</p>
<ul>
<li>At work, my boss is wondering if there is a way for us to determine *ahead* of time if queries being generated by our web service are going to really churn the database and lock things up.  Since the queries are very dynamic, I can only do so much in the caching department.  Application is PHP-based, built using Code Igniter</li>
<li>Inspired by <a href="http://twitter.com/jperras">my friend Joel</a> feel free to share your essential <a href="http://www.vim.org">VIM</a> plugins.  Mine are <a href="http://www.vim.org/scripts/script.php?script_id=1075">netrw</a>, <a href="http://www.vim.org/scripts/script.php?script_id=2009">autoclose</a>, <a href="http://www.vim.org/scripts/script.php?script_id=2507">0scan</a>, <a href="http://www.vim.org/scripts/script.php?script_id=39">matchit</a>, <a href="http://www.vim.org/scripts/script.php?script_id=2602">paster</a> (I use it all the time at work), <a href="http://www.vim.org/scripts/script.php?script_id=1697">surround</a>, <a href="http://www.vim.org/scripts/script.php?script_id=273">taglist</a>, <a href="http://www.vim.org/scripts/script.php?script_id=90">vcscommand</a> (although I have started using a git plugin that I can't find the download page for, and then a bunch of syntax highlighting plugins for <a href="http://www.vim.org/scripts/script.php?script_id=1487">Django</a>, Git, PHP (can't remember which one), Python (can't remember which one) and <a href="http://www.vim.org/scripts/script.php?script_id=803">Xquery</a>.</li>
</ul>
<li>Tools for refactoring in other languages look awesome (<a href="http://gilesbowkett.blogspot.com/2008/09/towelie-keeps-your-code-dry.html">Towelie</a> for Ruby, <a href="http://rope.sourceforge.net/">Rope</a> for Python.  What tools are out there for PHP?
</li>
</p>
<p>
Let me know via the comments what you know or find out.  Thanks and enjoy the Easter / Passover break!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.littlehart.net/atthekeyboard/2009/04/09/lazyweb-questions-april-2009/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
