This was written haphazardly in a forum, please take it as-is (or as a rant of some kind)!
Ok, so before I started using cake I went in to the #cakephp channel on freenode and asked:

“yes, but what about when my application gets really complicated?”
“don’t worry, it’s totally flexible”
“I love cake”

I was still skeptical, but we had a small project coming up at work and a fair bit of time to do it in. Cake fit the bill perfectly. A success!

We’re just coming to the end of a project say, 2 or 3 times the magnitude of that first one. I’ve now had time to form some real solid opinion about CakePHP.

CakePHP has some good points and bad points. One of the nice things about cake is it throws you into the MVC (Model/View/Controller) pattern way of thinking, and without having to learn ruby or something weird like that. The code I’ve been working on has been a lot easier to code because of this nice seperation..although in some cases it has taken slightly longer.

For example, a simple login form can take slightly longer to make as you have to create an login action member to your controller (a function), and then the view (template) and then the model (I’ll get on to that) rather than one quick bodge.

Having said that, I really like it so that gets thumbs up!

Now for why it isn’t quite as good as people say (or at least why I think it’s a bit shit). Models.

So instead of just doing $data = mysql_fetch_assoc($query, $handle) or whatever, you use cake’s ‘model’ abstraction layer, so you’d do something like $this->Model->fetch($data) or something..I don’t remember exactly.

There are a few problems with this:

First and foremost, you need to learn quite a lot, and it’s poorly documented for when you have many to many relationships etc..
CakePHP is poorly documented anyway!
It’s silly, because like a lot of these ‘bright’ ideas, it ends up being wayy more complex than just throwing in a simple (or complex) query.

Yes, for quite simple projects, you (me) could probably get away with using Cake’s modeling bit. However, for complex stuff, you’ll find you’re using $this->Model->query();

That brings me on to why I might continue to use cake in the future…

It’s nicely flexible, next time, I won’t bother trying to use any of Cake’s modeling features to get my data. I’ll just use normal queries..we found we were doing that by the end of the project anyway. I think for beginners, Cake’s modeling language *might* be easier to learn than SQL, but I know SQL and that works well for me…and you don’t have to be messy with it either.

Second thing I really like about cake is that a lot of stuff can be done for you by it’s helper library, for example, $html->dropdown() (or something to that effect) adds a drop down list from an array in your view.

What would be really cool is a cakephp without all the chaff of the model stuff…some kind of cakephp for people who know and love SQL perhaps?

Well, that’s my take on it. If you’re thinking about using it, first I’d suggest you think very hard. Cake is still in it’s infancy, and you’ll find quite a bit isn’t documented at all (I had to speaker to the developer to get some answers). Secondly, it might be easier/better..especially if it’s a one person project to write your own framework based around all this. I’m talking about a very ‘lite’ framework, perhaps just a few files, no more than 200 lines of code?

I’ve had a bit of experience writing my own framework, first one I tried sucked, second one worked really well and I’m now in the process of making a third simply for knocking up sites really quickly. How often do you find yourself coding the same things?

Happy baking!

Leave a Reply