<?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>daverupert.com &#187; CakePHP</title> <atom:link href="http://daverupert.com/category/cakephp/feed/" rel="self" type="application/rss+xml" /><link>http://daverupert.com</link> <description>Just another WordPress weblog</description> <lastBuildDate>Wed, 21 Jul 2010 00:50:43 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.0</generator> <item><title>What I’d like to see from Lithium #li3</title><link>http://daverupert.com/2009/10/what-i%e2%80%99d-like-to-see-from-lithium-li3/</link> <comments>http://daverupert.com/2009/10/what-i%e2%80%99d-like-to-see-from-lithium-li3/#comments</comments> <pubDate>Sun, 25 Oct 2009 06:03:52 +0000</pubDate> <dc:creator>davatron5000</dc:creator> <category><![CDATA[CakePHP]]></category> <category><![CDATA[LithiumPHP]]></category><guid
isPermaLink="false">http://daverupert.com/?p=594</guid> <description><![CDATA[My framework of choice forked this week, these are my (solicited) demands.]]></description> <content:encoded><![CDATA[<p><img
src="http://daverupert.com/wp-content/uploads/2009/10/li3.jpg" alt="li3" title="li3" width="200" height="250" class="alignright size-full wp-image-598" />This week my framework of choice <a
href="http://cakephp.org">CakePHP</a> forked.  Now there’s CakePHP (the mothership) and <a
href="li3.rad-dev.org/">Lithium</a> (the project formerly known as Cake3).  Let me tell you, oh people of the interwebs, it’s a weird feeling to wake up on a Friday morning to find out the leaders of your “online community” have parted ways and no one is really talking about it.  Kind of like in high school when 2 friends break up and you’re not sure who you’re supposed to hang out with.  The public breakup actually seemed very mutual and polite and the world appreciates the “less drama” approach.  Let’s look at the facts, CakePHP is still the excellent framework that it was on Thursday and development <a
href="http://bakery.cakephp.org/articles/view/the-cake-is-still-rising">is still</a> <a
href="http://www.youtube.com/watch?v=grbSQ6O6kbs">going on</a>.</p><p>And to keep myself upbeat about the whole situation I like to pretend there was a board room meeting where Larry Masters raised his arms and said “Go forth @gwoo and @nateabele! and continue with us -not as enemies, but as friends- to bring the good news of PHP to the world!  We are all lions!  There can be many prides!”&#8230; and then Mark Story did some kind of run-up-the-wall backflip because he is amazing&#8230;</p><h3>Nate&#8217;s Question</h3><p>Backstory complete, Nate posed the question on Twitter about <a
href="http://twitter.com/nateabele/status/5115656524">what people would like to see from Lithium</a>.  I knew my answer wouldn’t fit into 140 characters so I thought I’d post it here.</p><h3>File Uploader Class</h3><p>My first dream utility would be some kind of built in File Upload mechanism (component, behavior, I don’t really care).  I have had a long sordid story with uploading:</p><ul><li>First it was a custom jobby that got exploited pretty quick.</li><li>Even when I did patch it, I was always stressed out about it.</li><li>Then I used one of the upload components from CakeForge.</li><li>Then about a year ago I switched to MeioUpload which rules, but after a year of use I&#8217;m starting to see the imperfections in it.</li></ul><p>The general attitude in the CakePHP community seemed to be sort of “we don’t have that” and “figure it out for yourself”.  But let’s be honest, we live in the <a
href="http://search.twitter.com/search?q=%23lazyweb">#lazyweb</a> and most real world applications involve some kind of uploading.  Usually it’s creating a method for some computer illiterate person to upload a CSV or a PDF.  But in the era of audio/video and media rich  apps, the need for any framework to possess a standardized uploading class+handler is inherent. A canonized Uploading Class makes perfect sense.  I have high hopes for something like this to come to Lithium because it appears that the creator of CakePHP’s Media Plugin, David Persson, has also defected.  But so far his Twitter stream has given few clues to anything like this, just <a
href="http://twitter.com/nperson/">cryptic messages about pyramids, sunsets, and bicycles.</a></p><h3>Image Editing Class</h3><p>Another idea would be some kind of Image Manipulation/Editing class. This idea I got from <a
href="http://twitter.com/jaymorrow/status/4990706954">this tweet</a>.  Just like uploading the chances that your modern day app is going to run into images and/or image editing is HUGE.  I suppose this runs into a “Which javascript framework do we use!?!?” dilemma, but we all know that jQuery is the right answer here.</p><h3>Other Ideas</h3><p>Any other ideas would be toward making useful applications, because I’m a more User Experience oriented person.  If I were to put myself on an MVC spectrum, I’d be here:</p><p><code>[DATA] Model ------------------------ Controllers --------|------------- Views [UX]</code></p><p>Just a tip for the Lithium Team, the secret to becoming an awesome framework is to make yourself completely accessible to n00bs.  Have little bits that give your framework some “killer feature” eye candy.  Extract mundane tasks like comment systems, rating/digg counters, geolocation, event calendars, et cetera into pre-packaged add-ons.  I realize the developers of Lithium probably want to keep things lightweight and generic -and they should because it makes the framework more nimble- but some kind of cabinet of “Almost-Core” add-ons would be killer.  Sort of like CakeForge Snippets and the Bakery intended to be before they got all super confusing.</p><h3>Meeting Biggs Darklighter* at Subway</h3><p>As for my decision whether or not to “Join the Rebellion” who knows.  I really like CakePHP and having used it everyday for over the last 3 years I feel like I’m just hitting my stride.  I feel like I can do anything with it.  And probably more importantly, as long as I have production servers that are PHP4.3.9 (gasp!) and PHP5.2.6 with over 40 live sites I won’t be leaving CakePHP anytime soon.</p><p>On the other hand, some of my most memorable help on the IRC has been from Lithium’s Gwoo and Nate (as well as Mark Story who is already an established bad ass). So based on loose *never actually met* e-relationships Lithium seems like a more natural choice.</p><p>It will ultimately come down to the new programming cliche “<em>Choose the framework that’s most suitable for the project</em>” (CTFTMSFTP, for short).  It’s like Subway**.  There’s no rule that you can only order one sandwich for the rest of your life.  It’s simple: choose the one you want to devour at the moment, pay the lady, and move on.  Sometimes it’s CakePHP, sometimes it’s Lithium, and sometimes (gasp!) it’s Ruby on Rails.</p><p>Hopefully that metaphor changed your life like it did mine.  Otherwise, I’m excited for Monday when <a
href="http://twitter.com/nateabele/status/5126680208">my Ponies Class for Lithium is unveiled to the whole world</a>.  And although my hands are tied to lower PHP versions for awhile, I’m excited to see what comes of the whole Lithium project.</p><p
class="small">* This is a reference to a scene cut from Star Wars IV: A New Hope http://www.starwarsholidayspecial.com/swcs/episode4/Biggs.html<br/><br
/> ** Full disclosure: I want Subway to sponsor my life.  If you can make this happen, email me.</p> ]]></content:encoded> <wfw:commentRss>http://daverupert.com/2009/10/what-i%e2%80%99d-like-to-see-from-lithium-li3/feed/</wfw:commentRss> <slash:comments>7</slash:comments> </item> <item><title>4 Best CakePHP Behaviors</title><link>http://daverupert.com/2008/12/4-best-cakephp-behaviors/</link> <comments>http://daverupert.com/2008/12/4-best-cakephp-behaviors/#comments</comments> <pubDate>Mon, 08 Dec 2008 15:00:51 +0000</pubDate> <dc:creator>davatron5000</dc:creator> <category><![CDATA[CakePHP]]></category><guid
isPermaLink="false">http://teampvel.paraveldesign.com/?p=247</guid> <description><![CDATA[I love CakePHP Behaviors.  They're the best way to quickly add robust features to your web app.  I boiled it down and found 4 that I really like.]]></description> <content:encoded><![CDATA[<p><a
href="http://cakephp.org"></a><a
href="http://daverupert.com/wp-content/uploads/2008/11/new.png"><img
class="alignright size-thumbnail wp-image-263" title="new" src="http://teampvel.paraveldesign.com/wp-content/uploads/new-150x150.png" alt="" width="150" height="150" /></a><a
href="http://cakephp.org">CakePHP</a> is our framework of choice here at <a
href="http://paraveldesign.com">Paravel</a>.  I spend a lot of time on <a
href="http://cakeforge.org">CakeForge</a>, <a
href="http://bakery.cakephp.org">The Bakery</a>, the <a
href="http://book.cakephp.org">Cookbook</a>, and the <a
href="http://api.cakephp.org">API</a> looking for code and examples either A: because I sometimes don&#8217;t know what I&#8217;m doing, or B: I want to know THE best convention to for the answer I&#8217;m looking for.  </p><p>After countless hours of using these mind-altering codes, I -<em>authoritatively</em>- present to the Top 4 Behaviors that everyone should be using in their apps&#8230; or else&#8230;</p><h3>#4 Containable</h3><p>This is hot off the shelf and new to CakePHP 1.2 and it makes a world of difference.  When querying items in the database, Cake likes to <code>SELECT</code> records wtih all it&#8217;s belongsTo, hasMany, and HABTMs (&#8220;habtems&#8221;) auto-magically associated. With the <a
href="http://book.cakephp.org/view/474/Containable">Containable Behavior</a> you can stop all that nonsense and speed up your app by having it <em>contain</em> the <code>JOIN</code> to a &#8220;short list&#8221; of approved &#8220;models&#8221;&#8230;</p><p>The Containable Behavior is like the bouncer at a fancy Hollywood club where if you&#8217;re not on the list, you get kicked to the curb and have to watch all the other &#8220;approved&#8221; models go by.  Hot, hot models.</p><p>More concretely, let&#8217;s say you had a Posts table and you wanted to get only the comments in the view, while simultaneously ignoring all the Author, Tags, Categories, etc.</p><p><code>/app/models/post.php</code></p><pre class="brush: php;">
class Post extends AppModel {
  var $name = &quot;Post&quot;;
  var $actsAs = array('Containable'); 

// forgive the over-simplification of these.
  var $hasMany = array('Comments');
  var $belongsTo = array('Author');
  var $hasAndBelongsToMany = array('Tags','Category');

}
</pre><p><code>/app/controllers/posts_controller.php</code></p><pre class="brush: php;">
function view_a_post_with_only_comments($id = null) {
  if(!$id) {
    $this-&gt;Session-&gt;setFlash('You forgot the ID number.');
    $this-&gt;redirect('/');
  }
  $this-&gt;Post-&gt;contain('Comment');
  $this-&gt;set('posts', $this-&gt;Post-&gt;read(null, $id));
}
</pre><p>It&#8217;s that easy! now you&#8217;ll only be pulling the Post and the Comments!  ka-chow!  This</p><h3>#3 Tree</h3><p>I love trees.  My wife has a particular affinity towards them.  If you like trees then you will be a fan of this behavior.  If you do not like trees, <a
href="http://www.ucbcomedy.com/videos/play/2692">I suggest you eat a bowl of hair because you are a du-mmy</a>.  Over the course of the last year I&#8217;ve made a few category systems in my apps and all of them left me feeling like i did something wrong and/or patched the code together in a terrible way.</p><p>Enter <a
href="http://book.cakephp.org/view/91/Tree">Tree Behavior</a>!  It&#8217;s been around forever and a half, and I don&#8217;t know why I didn&#8217;t use it, but it makes organizing things like categories, forum posts, comment threads, etc a whiz!  All you need is to add another couple of fields to the database and then add one line to your model.</p><p><code>categories.sql</code></p><pre class="brush: sql;">
create table categories (
  id integer 11 auto_increment,
  name varchar 50 null,
  parent_id integer 11 null,
  rght integer 11 null,
  lft integer 11 null
); engine=MySAM encode=UTF-8
</pre><p><code>app/models/category.php</code></p><pre class="brush: php;">
class Category extends Model {
  var $name = 'Category';
  var $actsAs = array('Tree');

// ideally categories should describe something,
// so this is just an example association.

  var $hasMany = array('Post');
  ...
} ?&gt;
</pre><p>Now you&#8217;re cooking with grease!  It will automatically keep track of your tree structure &#8211; who comes before this, who comes after (&#8220;left and right&#8221;), who is the parent, etcetera.  Couldn&#8217;t be easier.</p><p>Move on to the next page for the Top 2 CakePHP behaviors:</p> ]]></content:encoded> <wfw:commentRss>http://daverupert.com/2008/12/4-best-cakephp-behaviors/feed/</wfw:commentRss> <slash:comments>1</slash:comments> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk
Page Caching using disk (enhanced)
Database Caching using disk
Object Caching 223/247 objects using disk

Served from: daverupert.com @ 2010-07-29 12:17:23 -->