Just a quick one, as I am sure that you have already read, but I am extremely pleased to tell you all that CakePHP has been released as a final and stable release. This means no more alpha’s, beta’s or release candidates. Get it while it is hot, as it is very HOT!

Big congrats go to Nate, Gwoo and all the core team. Well done guys! On to 1.3…

Cake Nibbles #3

19 Dec 2008 In: CakePHP

This will be a short edition of Cake Nibbles, and I suppose, a bit of a Christmas special.

CakePHP RC4 Released

First up, and the reason for this short, but special edition, is that last nights announcement of release candidate 4. Even though RC3 was announced as being the last RC before a stable version of CakePHP 1.2, it seems that this new release is actually the last RC. I’ve mentioned this before, but I really wish that the core team would adhere more to the “release often, release early” principle. I really don’t see how Cake could become any more stable, and unfortunately don’t think we have any chance of seeing a final stable release by Christmas. But I am encouraged by Nate’s promise of a final release “very soon” after this release. We shall see…

CakeBattles

James Fairhurst continues to impress. He just announced and released another fun application built with Cake.

CakeBattles is an online application that allows Contenders to be pitted against each and allows users to vote on who/what would win. Each Contender can be assigned to multiple Tags which are used to create battles with similar Contenders. Each Contender can also have multiple images and these are displayed at random to keep the battles fresh.

I wish I could just write a fun little app, But instead I find myself drawn to very large and complex apps, that I never seem to get finished. Fun to do, but all a little pointless if they never get finished. So hats off to James.

And that’s about it for now. All that remains for me to do now, is to wish and yours a very Merry Christmas and a happy new year. Have a good one!

CakePHP plugins that love Git

4 Dec 2008 In: CakePHP, Git

Since the announcement of the DebugKit plugin, and its source control taking place on Github, there have been a slew of Cake users placing their code under Git control, in particular, on Github. So I thought I would give you all a run down of the great and good in Cake/Git land.

DB Migrations

Oh come on! You didn’t really think I wouldn’t mention this one did ya? The easiest and best way to manage your database schema has been Gittified for a few months now. And already the new wiki has received contributions from people other than me.

Named Scope

Last one of mine - I promise! Inspired by a Ruby on Rails feature, Named Scope is actually a very powerful and useful addition to Cake. I’ve started to use it extensively in my Cake apps. You really should check it out. You’ll wonder how you ever got by without it.

Debug Kit

Probably the most popular Cake repo controlled by Git and Github, this extremely useful plugin places a small bar at the top right of your app’s pages, presenting you with debugging data, such as your DB log, view variables, and params. This should be part of the core, and is the best example of how Git can really help with developing open source code, and encouraging others to contribute. It has already been forked several times.

Rafael Bandeira’s Plugins

Rafael Bandeira created a couple of model behaviors, and has made them available on Github for all to see. One in particular sticks out and impresses, and that is the Lazy Loader behavior. This will allow you to get related model data with simple, readable and nice method calls. His blog explains more.

Wildflower

Wildflower is a very promising “Content management system and application platform built on the CakePHP framework and jQuery Javascript library”. I actually discovered this after a tip from Nate. If handled well, this could mean good things for Cake.

Story Scribbles

Cake’s very own Mark Story now has a Github repo full of lovely little Cake ’scribbles’. Enjoy things such as his ACL based Menu component, web service behavior and his Geshi helper.

Felix’s Scraps

Another bunch of Cake bits and bobs, but this time from Felix Geisendörfer, he of Debuggable fame. What interests me the most is his collection of datasources, allowing you to connect your Cake apps to external services such as Akismet, Amazon and Google.

These are just what I feel are the pick of the crop, but there is a lot more than I originally thought on Github, including an alternative migrations shell, that doesn’t rely on Pear, and that just might spur me on to get rid of my reliance on the MDB2 library.

The Cake community seems to be loving Git right now. I only wish the powers that be will make that decision to switch.

Cake Nibbles #2

26 Nov 2008 In: CakePHP

Welcome to the second edition of Cake Nibbles; where I tell you all about the latest goings-on in the world of CakePHP.

Cook Book goes open source

First up is the news that the Cake Cook Book has been open sourced. The best part of this news is that it uses Git and not Subversion for its source control. This is great news for the Cake community, and what is even greater is mentioned next…

Chew on The Chaw

I was a little puzzled at that one as well, and to be honest I still am. But as you may have noticed, the CookBook was released on a new service called The Chaw. The Chaw is similar to GitHub, in that it lets you host your Git repositories, and manage them online. But what sets The Chaw apart from Github, is that it also provides a ticketing/issue management system, which is something that Github sorely lacks. So apart from the name (what the hell is a Chaw?), this is great news.

CakeFest #2

December 2nd, will see the start of CakeFest #2. The second official CakePHP conference will take place in Buenos Aires, Argentina between December 2nd and 5th, and is looking every bit as promising as the first CakeFest was in Orlando earlier this year.

New release of ModelBaker and appearance at MacWorld

A few months ago I blogged about a promising new Mac application called ModelBaker. Well, a new release has just been announced, as well as news that ModelBaker will be in attendance at MacWorld Conference in January. Of course, it is still in closed Beta, but I do have access to that, and still intend to provide a short review and more info on that as soon as I can.

NamedScope for CakePHP

20 Nov 2008 In: CakePHP

I discovered the joys of NamedScope for Ruby on Rails quite a while ago now, and have always been an admirer. Its makes performing finds on models very elegant and convenient, by automagically creating model methods based on your pased scope params. Just like this:

Named Scope in Rails
  1. class User < ActiveRecord::Base
  2.   named_scope :active, :conditions => {:active => true}
  3.   named_scope :inactive, :conditions => {:active => false}
  4. end
  5.  
  6. # Standard usage
  7. User.active    # same as User.find(:all, :conditions => {:active => true})
  8. User.inactive # same as User.find(:all, :conditions => {:active => false})

Then a few months ago I read this blog post and discovered that someone had created similar functionality for CakePHP, in the form of a model behavior. Although it’s not quite as powerful as it’s Rails cousin, it does let you define named scopes for any model quite easily. However, I wasn’t crazy about a few things.

Named Scopes are defined like this:

Don't like this:
  1. class User extends AppModel {
  2.   var $actsAs = array(
  3.     'NamedScope' => array(
  4.       'activated' => array('User.activated in not null'),
  5.       'online' => array('date_add(User.last_activity, interval 5 minute) > now()')
  6.     )
  7.   );
  8. }

The above format means we can only pass find conditions to a named scope, and cannot pass any other params, such as ORDER and FIELDS.

Then a named scope is then called like this:

this is not nice either
  1. $this->User->find('all', array('scope' => 'activated'));
  2. $this->User->find('all',
  3.   array('conditions' => 'points > 10', 'scope' => array('activated', 'online')))

I have to pass enough params to a find call as it is, so I don’t want anymore.

What I want to do is this:

This is better
  1. class User extends AppModel {
  2.   var $actsAs = array(
  3.     'NamedScope' => array(
  4.       'active' => array(
  5.         'conditions' => array(
  6.           'User.is_active' => true
  7.         ),
  8.         'order' => 'User.name ASC'
  9.       )
  10.     )
  11.   );
  12. };

and this

Easy peasy!
  1. $active_users = $this->User->active('all');

I can even do this:

This is just lovely
  1. $active_users = $this->User->active('all', array(
  2.     'conditions' => array(
  3.         'User.created' => '2008-01-01'
  4.     ),
  5.     'order' => 'User.name ASC'
  6. ));

Much improved I think, and so much more powerful. So I’ve only gone and coded the damn thing! You can find my version of Named Scope for Cake on Github at http://github.com/joelmoss/cakephp-namedscope.

And you know what? Thanks to the power of CakePHP, the actual code is seven lines shorter than the aforementioned version.

Who is Developing with Style?

My name is Joel Moss, a web developer and all round nice guy, living in Manchester, England. I am currently working full time for ShermansTravel.com, but I fill whatever spare time I have with lots of good and wholesome "stuff"! Like developing my own ideas; such as Tooum, contributing to the excellent CakePHP framework, and doing more work for ShermansTravel.

So this is my blog - my soap box! Here I attempt to share my likes, my dislikes, and my opinions. As well as providing some occasional respite from the daily crap we all endure. Enjoy ;)

Hey, if you want to reach me, i'm available via email:joel[at]developwithstyle[dot]com, and AIM:joelkmoss.


Twittering...

Categories

Archives