More Impressions of CakePHP

A few weeks ago I wrote my early impressions of CakePHP. In this post I’ll share my thoughts on the mystical “bake” function, SEO-friendly URLs, and intuitive code.

So bake turned out to be more and less than I expected. The good news is it can get the skeleton of your site code up in a hurry. I found this to be particularly useful with the model files that defined the relationships between tables. (CakePHP uses the MVC architecture.)

In a very impressive feat, you can also bake scaffolding views that create all the HTML forms you need to enter and manage data for your application. The scaffolding is impressive in how well it accomplishes what it sets out to do. The bad news is what it sets out to do has no value in your final web site. I suppose it allows you to add test data a little easier, but at that it is only marginally easier to use than phpMyAdmin, which gives you near complete database management.

The other aspect of bake that seemed unnecessary complex to me was that I had to run it from a command line. I’m sure there’s a reason why it was designed this way. As a user, though, my preference would be to run this from a web browser. Since I don’t manage my own server, I had to make special arrangements with my hosting provider to get command line access. It also feels slow and clunky to be entering configuration options one at a time into a command prompt.

Before ever touching CakePHP, I had years of experience with Fusebox. So when I’m evaluating Cake, I’m usually measuring how it stacks up with that other framework I know so well. One area where it takes the cake (I’m so, so sorry) is creating pretty URLs. A URL in Fusebox looks fairly atrocious. Here’s a typical one:

http://www.yoursite.com/index.php?fuseaction=authors.list&active=true&language=en

You can take steps to use more attractive URLs if you use Apache’s mod_rewrite module, assuming Apache is your web server. Cake takes care of all of this for you without any additional work. The same URL in Cake might look something like:

http://www.yoursite.com/authors/list/active/en

I did experience a few pleasant surprises while working with CakePHP. There were several times when I found myself trying to figure out how to do certain tasks in Cake. Even in cases where I’m fairly certain I had not come across any examples of the task yet, I was able to “guess” correctly how to accomplish the task based on what I had learned of Cake up to that point. I still had head-scratching moments of frustration, but I concluded that Cake is written to be fairly consistent and intuitive as you work with it.

It’s worth noting that the last time I picked up a new framework was a few years ago. Is Cake truly more intuitive than Fusebox, or was I learning faster because I have several more years of programming experience under my belt?

Leave a Reply

Best Practices

presented by Site Potion