Book Review: CakePHP Application Development post
A few weeks ago I was approached by Pakt Publishing and asked if I was interested in reviewing the recent CakePHP book 'CakePHP Application Development' by Ahsanul Bari and Anupom Syam. In the interest of full disclosure, I have communicated with Ahsanul a few times via the CakePHP mailing list and on Twitter. We're not total strangers, more like casual acquaintances who know each other through the CakePHP community.
One of the biggest criticisms in the past of CakePHP was the lack of published documentation on how to use the framework. As shocking as it was to me, there were people who preferred a paper copy of the Cookbook so they could have access to it when they might not be online (what, working on your computer and not online?!?) or to read offline. Naturally, several books about the framework have been published in the past few months, and I can't think of a better book to recommend to people interested in learning the framework than this one. And I'm not just saying that because I got a copy for free. While the book is good, there are a few places where it could be even better.
The Good: Examples, Example, Examples
The target audience for this book is the right one that CakePHP is attracting: intermediate PHP developers who may have not used a framework before and are trying to figure out how to use one to their advantage. Without clear and relevant examples of how to use it, CakePHP would be just another framework struggling to gain acceptance with the PHP deveoper community. If you want examples on how to do most basic things with CakePHP, this book has them. Want to know how to configure CakePHP to work for your web server? Check! How do you get results from your database? Check! How do you use the 'bake' utility from the Cake console? Check! Validating form fields? Check!
I feel that the examples in this book are it's strengths. The code is well written and every code example is followed by an explanation of what they are doing. Many times the example is not enough, you have to understand WHY it's written that way.
The Good: Sample Applications Always Help
The Bad: Less Info On Doing Things The Cake Way
I feel that some more time could've been spent explaining CakePHP's "convention over configuration" preferences and how it changes the way you approach building an application using CakePHP. Perhaps that wasn't a topic for this book's intended audience, since it's only the deep thinkers and the rant-and-ravers (which I have been accused of belonging to) who like to discuss the philosophy behind CakePHP and the question of just what a framework is good for.
The Bad: Thin on Server Configuration Information
While there is a chapter devoted to getting CakePHP up-and-running using Apache and MySQL (specifically using WAMP), it would've been very helpful to see an example of the type of configuration recommended for production environments, where the APP directory is web-accessable while the CakePHP core is located somewhere outside the webroot, linked in via an option in the configuration files.
The Bad: No mention of the differences in debug levels
When I do my development work on a CakePHP application, I set the debug level to 1 so that I see all errors and the SQL statements being generated by my models. In production I have the debug level set to 0 as I don't want error messages on the screen that reveal any information, and I certainly don't want people seeing the SQL statements being executed. Sure, it's security by obscurity but it's also debugging information that's cluttering up the screen.
The Bad: No mention of using the built-in testing
While I'm a lapsed tester, the fact that CakePHP will create the shells for writing unit tests for the models and controllers you create should not be overlooked. Although testing gets a bad rap ("It's too hard, and it wastes my time!") it's a programming practice that should be encouraged.
The Ugly: CakePHP is still a moving target
While this in no way diminishes the efforts put in by the authors to create this excellent introduction to CakePHP, at the time it went to press CakePHP 1.2 was still not feature-final. Some tihngs have changed, and I expect some more things will change before CakePHP 1.2 is finalized and work on CakePHP 2.0 starts. This is the danger in writing about any programming language: the information could become obsolete at any time. But don't get all upset about it, as it is likely only very minor details that have changed. The CakePHP core team does try to not break things *that* much.
So, don't let the number of "bad" issues above dissuade you from checking out this book. The items I highlighted are probably bettered suited for a "Advanced CakePHP Application Development for Grumpy Developers" book. I would not hesitate to recommend this book to any semi-experienced PHP developer who is looking for a resource guide to get themselves started.