So, I’ve been playing with CakePHP lately for a project I’m working up. I have to admit, it’s nice – very nice. I can see what all of the fuss is about.
Having used the Zend Framework for a project (a pretty important one, at least to me), I’ve had a bit of experience with the whole MVC style of development. I understaood what the parts did and how they fit together, but the actual development process was still a bit of a mystery to me until I really got into the ZF. I developed my application, worked up a pretty good site, and had things going along swimmingly.
Then I figured I’d give another framework a try for this other project. So, being the (brave?) soul that I am, I switched over to Cake. I have to admit, right off the bat, I almost ran screaming back to the Zend Framework. I was faced with a fully installed framework with a different structure than I was used to, different naming conventions and locations than I knew, and one big thing I wasn’t used to using coming from Zend – models.
So far, I’ve only used the models to act as interfaces to the database tables of their same name, but I know there’s more to them than that. Those working with the Zend Framework might not quite get how they’re used if you’ve never done any other MVC work outside of the Zend Framework, so here’s a bit of a basic summary as best I can tell:
Models are a “go between” for the controller and the view. The controller can look at and use the view to understand what the resource is like behind the scenes and use that to run code to output to the view. In the Zend Framework, since models aren’t even there, pulling information from and pushing data into database tables requires ensuring you have your SQL statements right to make the updates. In Cake, it’s as easy as calling the save() function in the controller and letting the framework (including the model for the table) so the rest.
Switching from one to the other was interesting – naming conventions and locations are less important to the Zend Framework as they are to Cake. Cake has a place for everything and everything in its place. There are directories under the views for the pages of each controller, helpers for each of the MVC components (components for controllers, helpers for views, and behaviors for models), and plenty of “magic methods” to go around.
I know I’m only getting started with Cake, but I do like what I’ve seen so far, and I know that there’s so many features of the framework that I’ve only touched on, but I’ll get there. I promise.
Oh, and, in a parting note, I have to compliment both frameworks on doing an excellent job on documenting their functionality. There might be a few little issues here and there, but over all, they both make life a lot easier through a few simple web pages.