YYZtech.ca

CakePHP Applications Development

Learning the CakePHP 1.2 framework though examples.

By: Staff

AdSense

What is Cake?
Along with others like Zend's framework, symfony and CodeIgniter, CakePHP is one of the most popular PHP frameworks around today, Originally inspired by Ruby on Rails, it incorporates a number of features that can speed up application development: code generation,"convention over configuration" (i.e. it expects placement of files and names to follow certain rules) and common design patterns like MVC and ActiveRecord that can help keep your code maintainable. It's this ease of development that has made it popular.

Cake, like 'Rails, is also an example of a "full stack" framework, as opposed to "component frameworks" like Zend's. The easiest way to think of the difference between these two kinds is: with Cake (or symfony, another full stack framework) you are most productive when you understand where the framework expects to find things and what it expects them to be called; if you follow these conventions, you'll find Cake takes care of a lot of details for you. The catch is you generally have to buy into the whole framework-- you can't really pick what parts of your project will use the framework and what won't-- though Cake will allow you to incorporate libraries that don't use it's structure. As well, there is a bit of a steeper learning curve as you have to understand how the whole thing fits together. On the other hand component frameworks give the developer more choice about what parts of the framework to use as these frameworks are designed to be used in pieces, but the trade off is you tend to have to configure and specify things more as a component framework can't make the same assumptions about how things are organized, because they are designed so the parts can be used individually. So full stack frameworks might let you build applications quicker, but you have design with their way of doing things while component frameworks let you choose what will be handled by the framework, but put more of the burden of setting things up on the developer.

Learning the rules of the Cake framework has been a challenge in the past both because of poor or out-dated documentation and though the official documentation has improved immensely in the last year, it doesn't aim to teach Cake to complete beginners. Packt's book is one of two English-language books released this summer covering the CakePHP framework (the other being Apress' Beginning CakePHP ).

Packt's CakePHP Applications Development does take reader though all the steps right from downloading Cake and installing it on a server running either Windows or Linux. The server documentation isn't that detailed -- I hoped they'd show how to set up multiple projects using virtual directories or similar-- but it should get people started. After an introduction to the under-laying MVC pattern that Cake uses, the book then takes the reader though setting up Cake and creating a simple data-base driven application, CakeToDo. The next four chapters cover Cake's implementation of controllers, models and views. Later chapters build a more complete application, QuickWall, that incorporates a lot more of Cake's features including user log-in with the Auth and Email components. Near the end of the book Ajax and generating RSS feeds is covered too. In general what it does cover is pretty good. There are plenty of "What just happened?" sections that explain in some detail what a particular block of code is doing. As well, there is a lot of tips that, like how to create a controller without a model or watching out for "<?php ... ?> " (trailing spaces) in models/controllers that can cause hard to find errors (Zend Framework's guidelines suggest leaving off the closing PHP tag for this reason). This book will give readers new to Cake a solid foundation for writing applications.

What doesn't this book teach?
Unfortunately cake 1.2 is still evolving even at the time this review is being written. While you can't fault the authors, there are a few things that have changed, for instance, the often-usedgenerateList() has been deprecated and the SQL operators have switched places (e.g. " 'User.name !=' => 'Joe' " instead of " 'User.name' => '!= Joe' ) when specifying model find conditions are two changes that come to mind. As well, there is no coverage of the very useful containablebehaviours as an alternative to adding/removing bindings (which showed up probably after the book was written). Speaking of "behaviours", there is no coverage of them in the Model chapters. Some components are covered like Auth, Email, but other like ACL or the very useful Set core component aren't. Neither is there much coverage of security, but in that regard, Cake Applications isn't alone-- many beginner books overlook that aspect.

Way of the Cake
Finally, a few of the reviews have mentioned that there isn't much coverage of doing things "The Cake Way", or how to decide how to solve a problem in a way that fits in with the framework logically. To to honest, this is kind of a step beyond beginner and its something that shows up in blogs and posts to the Google Group mailing list frequently. I think as long as coders keep a few rules in mind, like try to keep as much logic out of the View end of MVC, and don't go changing the files in the /cake directory, then it's probably OK.

Closing
I started frameworks using symfony a few years ago and just learning how things where organized was a major hurtle. Cake, I believe, has a simpler structure, and does a lot of hand-holding for developers. Other reviews of the book have pointed out that there are a few flaws with this slim 300-page book: primarily some out-of-date information, no coverage of the testing framework, localization or writing shell scripts, and doing things "the Cake way". I tried to approach this book as how useful it would be to someone unfamiliar with the CakePHP and I think it's a fair job. If Packt releases an updated version once the final 1.2 arrives, it would be excellent choice for new users, as it stands, it's still recommended with an asterisk.

[asa]1847193897[/asa]

Date published: 29-Oct-2008

AdSense

Comments

AdSense

Related

Professional CodeIgniter

Set your code on fire, professionally. Seriously, it's a bright red book about the popular PHP framework.

PHP and MySQL Web Development

Programming with PHP and MySQL with security in mind.

Learning jQuery 1.3

Learning to use jQuery to build better websites, though examples and popular plug-ins.

Coders at Work

Talking to programmers.

Algorithms in a Nutshell

Before picking an algorithm know what problem you're trying to solve.

Sponsored



2017 YYZTech



For American computers stores, visit: AmericanComputerDealer.com

Google+