CakePHP 2.0.0

CakePHP is mentioned in a few job advertisements. What is it? Should you learn CakePHP? Is the new 2.0.0 release ready for use?

CakePHP is a PHP based Web development framework competing against CodeIgniter, Symfony, Zend Framework, and a long list of other frameworks. There is a comparison in PHP or ..., CakePHP/Symfony/ZF versus .... Download CakePHP from cakephp.org.

Symfony claims to be the most popular framework world wide. Zend Framework is the most popular framework in Australian job advertisements with CakePHP and Symfony competing for a distant second. CodeIgniter used to be popular, used to be in the top two, and is now rarely mentioned.

Most frameworks give you a library of code you use to build something. CakePHP also includes a startup Web page application to test your Web site configuration and provide you with a basic starting point. +1 to CakePHP.

CakePHP is object oriented and the 2.0.0 code uses some of the latest features of PHP objects. Unfortunately some of the code is still 1990s stuff. 0 points for this. Update October, 2011. CakePHP version 2 has a stable release.

Naming conventions

Update May 31, 2011. CakePHP version 2 is undergoing a rename. One example is cake/libs/configure.php to lib/Cake/Core/Configure.php.

The CakePHP 1.3 naming conventions look like they fit fashion instead of logic. There are many inconsistencies. If you are familiar with the paintings of Jackson Pollock, you know what it would be like to classify his paintings by colour. CakePHP appear to use the Jackson Pollock painting approach to mix together every naming convention fashion. They then make it hard for you to change the names because they use one name to compute another instead of letting you specify each name. -1 for this approach.

Update May 31, 2011. The initial changes in CakePHP 2 might reduce this rating to -0.5. There will be more consistency in file naming. CakePHP 2 aims to follow the file naming convention proposed at groups.google.com/group/php-standards/web/psr-0-final-proposal and that proposal is inconsistent on several points. CakePHP 2 cannot be consistent if it is following an inconsistent standard.

Some of the inconsistencies:

Namespace names must be lower case but class names must have the first letter presented as a capital. Hey, what happened to the semantic Web? We are supposed to get rid of using case decoration to imply meaning.

Namespace names can contain underscores and are treated as names. Class names are the opposite, they are exploded on the underscore and the result is translated to a directory structure. The class name handling appears to be an importation of one of the worst features of Java. I hope CakePHP 2 will not enforce this ugliness on PHP developers. Who would want to replace 2 PHP style developers with 6 Java style developers?

Testing and startup

CakePHP version 2 is supposed to be better because all the code is tested automatically. Another big advantage of CakePHP over some competing frameworks is the included startup code to let you see CakePHP in action. You can work from a known starting point and test some things immediately.

I downloaded CakePHP 2.0.0 and it failed immediately with an obvious error, suggesting they never tested all the CakePHP code together as one release. Testing is useless if it does not test the basic things people do first. I suggest you skip CakePHP version 2 for any project you are starting early 2011 and revisit CakePHP 2 toward the end of 2011.

Update May 31, 2011. CakePHP 2 now has an official alpha release, 2.0.0 alpha. I have not tried it. The bug fix log mentions lots of startup errors fixed and lots of file renames. There is nothing to say all the startup errors and renames are complete.

I tried following some tutorials on CakePHP. I found nothing for version 2. There are some tutorials for the older 1.3 and 1.2 versions. There is enough mismatch between the old tutorials and CakePHP version 2 that I could not proceed beyond the basics of displaying a page, certainly not to the point of completing a basic form. Another -1 for CakePHP 2 in 2011.

Update May 31, 2011. I tend to write the documentation first, derive the testing from the documentation, then develop the code that does what is described in the documentation. Drupal documentation for the new release 7 featured several conversion pages so you could use the old documentation with the notes on what changes in version 7. I would not recommend CakePHP 2 for people starting a new project. Stick to Cake 1.3.

MVC

MVC is Model, View, Controller, and is a way to structure code to separate out the presentation layer. Modularised applications use HMVC, Hierarchical MVC, to add MVC structured modules to an MVC structured core application.

CakePHP talks about an MVC architecture and has an interesting structure that is closer to MVC than most other MVC frameworks I have used. The V part, the View, in CakePHP 1.3 still ends up as files with PHP and HTML mixed in a not so logical muddle. Some other frameworks beat CakePHP in the View area. No points either way on this point.

Conclusion

I might battle on with CakePHP for a test although I might scrap version 2 and go back to version 1.3. Update May 31, 2011. CakePHP 1.3 is the only CakePHP with documentation and the only choice for beginners. You might be able to learn CakePHP 2 if you have extensive experience with another framework, or CakePHP 1.3, and of reading code.Update October, 2011. CakePHP 2.0 is out in a stable release suitable for new projects if you can work without up to date documentation.

Comments

I think that this is a pretty un-educated review of a product. CakePHP 2.0 isn't out yet, it has only just been released to alpha. It is sort of like trying to move into a house that is halfway through being built and complaining that there are no walls or the (non-existent) roof is leaking...

Version 1.3 is pretty solid as it has been out for some time, 2.0 is getting closer to release and a recent naming convention change should satisfy your -1 score for that area.

2.0 is only really for use if you have been developing on cake for a while and know the inner workings, if this isn't you then 1.3 is the way to go for now.

Cheers and good luck!

Hello Dean, Thank you for your feedback. I expanded the text to emphasis that CakePHP 2 is not yet ready for someone new to CakePHP. Based on notes at the CakePHP site, I thought the previous download was the alpha release. I added updates after an initial look at the official 2.0.0 alpha release. Looking through the change log and across at some incident reports, I did not find anything to indicate the file name changes are complete, a reason to not use Cake 2.0.0 alpha if you are learning CakePHP.

The one good thing from the renaming could be the ability to mix frameworks together, which could make CakePHP a nice choice if you want to convert a site that was built on PEAR. I do not have any projects of that nature. I do have some conversions lined up for sites built on unmaintained non standard frameworks and like the idea of converting to a framework with a step toward future compatibility with other frameworks. The Zend Framework is my other choice for those projects and Zend is working toward the same standard as CakePHP.