Sharing technology, ideas, insights!
Call: +91 710 466 0336         Email:


CakePHP 3 is coming

“CakePHP 3 is coming” I said, a colleague remarked,  “Why are you saying it like – Winter is coming?”.

We have been working with CakePHP almost since its inception nearly 10 years ago. We have survived the winter of converting from version 1.2 to 2.0 with great benefits and I am eagerly looking forward to using CakePHP 3 for greater benefits. The roadmap document clearly states that CakePHP 3.0 represents a significant break in backwards compatibility.

Here are the high level goals of CakePHP 3.0

  • Adopt broader PHP community standards. Tools like composer, and PSR-0, PSR-1 have proven to be useful tools for improving interoperability. CakePHP should embrace these community standards where possible.
  • Increase modularity. CakePHP has had history of being tightly coupled. We’re trying to reduce coupling and make more standalone libraries. For example the new Collections library, and Events system have no dependencies on the rest of the framework.
  • Use PHP 5.4. When we started on CakePHP 3.0, this seemed ambitious. However, with the release of PHP 5.5, and impending release of PHP 5.6, it feels right on target now.
  • Modernize and simplify the framework. CakePHP has accumulated numerous features over the years. By removing some features that are better implemented as plugins we make CakePHP simpler and smaller for everyone. Separating features into plugins allows greater community involvement and more rapid iteration on features.

That is an awful lot to take in at one go but after trying out the CakePHP 3.0.0 alpha release I am convinced that for new projects this will an enormous boost in code quality as well as programmer productivity. I say new projects because a look through the migration guide will tell you that the changes are too huge to try to migrate a codebase unless you intend to use the same code for more than 2 years. I know I may draw some flak for this but commercially speaking many times the migration is just not worth it for the client. We are still supporting some 1.3 codebases.

What are the biggest takeaways for me?

The installation for CakePHP 3.0 is via Composer. In fact composer is supported throughout…

The biggest change is the ORM – it is a complete rewrite. The Model is now split into two – tables and entities. Table objects provide access to collections of data. They allow you to save new records, modify/delete existing ones, define relations, and perform bulk operations. Entity represents individual records and allow you to define row/record level behavior & functionality.

The third type of object which comes into play is the Query object. The table objects do not return the results immediately but they return a query object which can be very flexible to use as illustrated by the snippet below

As you can see the query was altered after calling find: Do go through the ORM Upgrade guide to understand more about it.

Validation is a service now! It also is much more flexible than before when it was coupled tightly to the model

A change which several developers are going to miss is removal of Scaffolding – I never used it /shrugs

The session class is no longer static, instead the session can be accessed through the request object.

ACL related classes were moved to a separate plugin. This probably is a welcome change but I am not sure. ACL always proved confusing to teach to newcomers for me. Once mastered the powerful concepts allowed for very fine grained control over the application.

Themes are now Basic Plugins – need to play around with this a bit more and probably will write a blog post on it.

FormHelper has been rewritten to use the new ORM and can also use other data sources. It also features an extensible widget system. (Picture upload which hooks into EXIF info anyone?)

Non conclusion

I wanted to write more but the changes are too many. Just enumerating them will not serve much beyond what is already there in the documentation which is changing and expanding on a daily basis. I just hope that I get some more time to write about the new features as I explore them more and more…

About the Author

Dr. Tarique Sani is a pediatrician and forensic expert by education. He is a PHP programmer of 'wrote the book' caliber and has to his credit several very popular open source as well as commercial PHP projects. He leads a team of dynamic programmers at SANIsoft who have in-depth understanding of Web scalability, development tools and usability practices with strong developmental skills in PHP, MySQL/PostgreSQL, HTML, Javascript, and Linux/Apache


  1. Pingback: CakePHP 3 is coming | Tarique's Travails

  2. Pingback: CakePHP3.0への移行の準備メモ | X->A->O

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.