CakePHP application development

Skip the preface and go directly to book review.

One of my main principles in development is: “Use a right tool for the job”. As an active web developer, I get different projects that require different approaches. My preferred framework is TYPO3, of course. But sometimes TYPO3 is not the best choice for the job.

While looking to one project I realized that it has to be done outside of TYPO3. I had to choose another framework. There are a lot of RAD (rapid application development) frameworks around. All of them are based on the MVC (model–view–controller) design pattern and implement CRUD (create–read–update–delete) and DRY (do not repeat yourself) principles. After evaluating several of these frameworks I decided to use CakePHP for that project. To prevent questions from TYPO3 developers: yes, I considered FLOW3 but still decided on CakePHP for some reasons that are not relevant to this review.

CakePHP is a very good framework. Combination of speed, features and ease of development is fantastic. Documentation is great. A developer can learn CakePHP enough to do practical projects if he follows the official documentation (TYPO3 community dream for ages!).

Why did I bother to get the book?

Firsts, I do not like reading from the computer screen. Neither it is healthy, not it allows to concentrate on the subject. Secondly, I believe in the practical learning approach, so I wanted a book, where I can learn CakePHP by programming a simple application. This is similar to what I did in my own book about TYPO3 extension development.

When it comes to books about programming, the very first site I visit is Packt Publishing. They have a best collection of titles for open source products. I went to their web site and discovered the “CakePHP application development” by Ahsanul Bari and Anupom Syam. Packt Publishing provided this book to me for review. Here I must emphasize that the review will be honest as anything else on this site. This review is not the advertisement of Packt Publishing or the book. It is my true opinion about the book.

The review

The book contains 306 pages. This makes it approximately 2 cm thick. It is paperback. The quality of printing, the font, the layout is traditional for Packt, which means “excellent and easy for reading”.

The book consists from tweleve chapters. Chapters are not numbered in the book, which I found a little inconvenient. When chapters are not numbered, it becomes harder to refer to the chapter. Here is chapter titles:

  • Introduction to CakePHP
  • A quick installation
  • A quick app
  • Controllers: programming application logic
  • Models: accessing data
  • ORM: modeling the table relationship
  • Views: creating user interfaces
  • Using shells: get further, faster
  • Making Quickwall: the basics
  • Quickwall: user authentication
  • Quickwall: JavaScript and AJAX
  • Quickwall: making it better

The book assumes the reader knows nothing about programming with CakePHP. It starts from telling the reader how to install the framework. This is a good approach for such book. You can get the book, download the package and start installing it while reading the book. Very practical!

Second chapter provides a quick “jump in” for the reader into the CakePHP by showing a lot of CakePHP functionality. Such chapters are great for readers because they provide a quick overview of concepts, rapid start and tell the reader if he was right to choose this framework. However such chapters are complex to writers.

Writers have to give details but not too much details. Too much details will blow the chapter up and reader can be lost. I must tell that writers of this book did it well: the chapter shows exactly as much as necessary. I wanted an explanation of some things (I like to dig deep from the beginning) and I could easily find all answers by either looking to further chapters in the book or to the CakePHP online documentation.

Just imagine, after completing the second chapter you already can start making simple CakePHP applications! Fantastic!

Next four chapters go into details about certain features of the framework. Controllers, models, views and database relations are discussed in the same easy manner. To my taste it was too easy sometimes. Of course the book is limited in size but I wanted more explanations for thing like “we will use this component, set variable X to Y”. I immediately became interested what other components are available and how do I know what variable to set to what value to use another component. The book definitely misses answers to such questions. On the other hand the reader can easily compensate this lack of information by reading the online documentation on the CakePHP web site. The book teaches the reader how to create applications, theory can be learned elsewhere.

Chapter about models surprised me a lot. I never knew that I can have an application that can do the following with only eleven lines of code:

  • Show a list of records (in pages if there are many records)
  • Show record details
  • Add new records
  • Delete records
  • Update records

Just imagine it: you have a database table and you need to quickly have an application that does all of the above. Eleven lines of code and you have it. Nicely formatted and everything. The book teaches you how. Some CakePHP users can tell that it is not a big deal because it is a built–in feature of CakePHP. Yes, it is built–in but the book described it very well and it also described how to customize this small application to a full real life application. As the reader remembers, I believe to the practical approach, so I liked the idea very much.

Database relations was especially interesting to me. CakePHP handles it well and this chapter describes how to do it. Probably this is the most complete chapter in the book. I had no questions at all after reading it. As before all information in the chapter is presented in the simple way, easy to understand.

Chapter about views briefly touches such CakePHP features like helpers. I wish developers dedicate a separate chapter to CakePHP helpers, components, plugins and vendors. This part is definitely missing in the book.

The remaining of the book describes the creation of the Quickwall application. Quickwall allows users ask and answer questions. These chapters describe customization of the application user interface, user authentication, AJAX handling in CakePHP, creating RSS feeds, etc. In other words these chapters cover most of the tasks that a typical developer will meet while making his own application.

Conclusion

While reading the book I remembered one of my professors in the university. He knew his topic so well that he assumed some things to be very simple. Once he spent 3 hours teaching us how magnetic fields interact with each other. He had to erase the blackboard several times because he did not have any space for new formulas. At the end of the lecture he said that this is one of two kinds of fields. He would not tell us about the other because it is like the first one, just the opposite direction. Obviously it was easy to him but after 3 hours of formulas we were left with anything but understanding. Fortunately I did not have that “opposite direction” question on the exam...

Why did I remember that? I had many questions while reading the book. The writers definitely know their topic. Sometimes they do not realize (like my old professor) that readers do not know about things the author consider simple and known. The reader can find the information in the online documentation but it distracts the reader from the book. This is a disadvantage of many such books, which I tried to avoid in my own book.

Another problem is that the book does not cover the latest version of CakePHP (1.2). Some examples in the book do not work and I had to search for the alternative.

Visual layout for the Quickwall obviously was not tested on FireFox. It looks bad. So if the reader is not a Windows user, he will have to fight the wrong layout himself.

Nevertheless the book is good if you want a quick start with CakePHP. It gave me most of what I wanted to know and left me feeling that I can program something simple with CakePHP and learn more if I have to. I would recommend the book the book for reading to anyone who makes his first steps with CakePHP.

The book is also available as printable PDF. Get the sample chapter from the book page.

This site is © Dmitry Dulepov, 2006–2010. Information on this site can be used in your work free of charge, though a donation would be very welcome!

Quoting is welcome but the link to this site is required. Translation and republishing requires an explicit permission.

dmitry-dulepov.com
"Fantastic blog!" (from TYPO3 mailing lists)