It is almost a year ago when I started seeing her, and ever since I am in love with her. From then on, I have been with her in quite a few projects, and she has never let me down. Its true that at times the relationship has not gone that well, but its mostly my fault. Either it was my lack of understanding her well or my impatience, or just the pressure of tight deadlines, that I ended up in uncomfortable situations with her. But she never let me down. Eventually, we made it through, and here I am one year later, writing about my beautiful relationship with Cakephp.
Oh hell! I didnt expect to get carried away this early, but contrary to what you are thinking, this article is not about my romance with CakePHP, but again, you never know when I start to get carried away For what little I have used this wonderful framework, it has been solely 1.1. Mostly due to lack of time, I never actually tried the new CakePHP 1.2. This is my attempt to get myself in tune with the latest release of CakePHP, and continue the romance. In my attempt to learn more about 1.2 (without getting into the code right away), I figured out that there is still no good documentation available. And whatever there is, are scattered across the web. Here I try to get them all together, and I hope this will help others to find 1.2 resources easily, and eventually help them adopt 1.2 faster.
Behaviours, With Association, enhanced validation, a new helper for form, built in pagination support, integrated unit testing and caching are some of the new features to name. But, if you are looking for a more clearer idea about what are the new features in 1.2, head right to the article by cakebaker called What’s new in CakePHP 1.2 ? The article clearly lists down all the major changes made in 1.2. Cakebaker also has an article that compares 1.1 and 1.2: Which Cake should you eat?. This will help you make your choice, but in my humble opinion, I still think 1.2 will be difficult for most people to start with, if they are new to CakePHP. The major reason being the lack of proper documentation. Having said that, most of 1.1 documentation will still work for 1.2, but there is the danger of using any deprecated feature or not taking full advantage of 1.2. If you are the type who likes the feeling of going into the unknown, then dive straight in 1.2. On the other hand, if you like to play it safe, and want complete control over what you are doing, you should go for 1.1. But again, my judgement might be totally wrong :p. Another reason, why you should start with 1.1 is that it will allow you to be in a better situation to comprehend the cool features that 1.2 comes with.
Ok! Enough of my opinions, now lets continue with the rest of 1.2 resources. The next one is by Nate: Bag o’ Tricks. This has random features of 1.2, that will definitely make your eyes go twinkling if you used 1.1 and never knew anything about 1.2. Having said that, I have the perfect link to follow: OCPHP. These are the presentation slides on 1.2 in the recently held OCPHP conference. A must see for any 1.2 wanna be.
One area where CakePHP 1.2 has really improved is in the built in validation support. In 1.1 there where only four validation rules: VALID_NOT_EMPTY, VALID_NUMBER, VALID_EMAIL and VALID_YEAR. The rest had to be hand coded. In 1.2 there are more validation rules than you will ever need: alphanumeric, email, maxlenght, url and phone are a few to name. To get a better picture of all the available rules and how to use them, follow the links below:
- Validation with CakePHP 1.2 by Cakebaker again.
- All about Validation in CakePHP 1.2 by Another Cake Baker.
- All about Validation in CakePHP 1.2 – Part 2 by Another Cake Baker
- Validation Gotcha in CakePHP 1.2 by Another Cake Baker
- Multiple rules of validation per field in CakePHP 1.2 by Mariano Iglesias
Cool! Enough of validation, and now its going to be something that is becoming more important as CakePHP is being used in high traffic web apps: caching. Proper caching of data can make your app improve its performance dramatically. CakePHP 1.2 comes with caching support right out of the box. At the moment, it has support for five different caching engines:
The default caching engine is file i.e. it uses the files to cache data. But, the most elegant thing about the 1.2 caching support is that it has a common interface for all the caching engines. You can change the caching engine and yet use the same code to cache. Also, you can use any other caching engine with the same interface. You can even combine all the caching engines appropriately by writing our own engine by wrapping different caching engines into it. Switching caching engine in the runtime is also possible. What else can you ask for? Links? Here they are:
- CakePHP 1.2 Cache by Jiri Kupiainen
- Optimizing your CakePHP elements and views with caching by Tane Piper
- Cache Elements Individually For Each User by Ketan
If you have used the bake.php script in 1.1, you will be amazed by the new console of CakePHP1.2. Basically, what the bake.php script did was that it allowed you to create models, controllers and view file structure ready for you(this is more commonly called baking) so that you have a structure ready for you to start working on. The new console takes this to the next level by allowing you to not only bake(auto generate code), but gives you access to different code from the command line. You can even use it to automate different tasks. This is something that I will most definitely write about more in the future, but for the time being, these links will satisfy your thirst:
- Setting Up the CakePHP Console on Windows. this is a screencast from the CakePHP site
- Setting Up the CakePHP Console on *nix, another screencast
- Update(31/08/07): Baking a bit faster with the bake script by Cakebaker
- Update(31/08/07): Faster baking of controllers with the bake shell script by Cakebaker
- Update(31/08/07): Baking Views by Cakebaker
Unit testing is something that has become vital for cooking bug-free(bug free? Im definitely kidding) apps. CakePHP 1.2 has integrated CakePHP test suite that uses SimpleTest. There isn’t much(just one) docs for this yet, but I am sure that this feature is so important, that proper docs will be available very soon. May be I can chip in . For the time being this is the only link I found, and it is from the bakery: Testing Models with CakePHP 1.2 test suite by Mariano Iglesias .
Wow! I cant believe you are still reading. I am already becoming tired of writing, so you must be tired as well, but thanks for being with me Frankly, I didnt expect this to get this long, but I still have some more links to write about. Don’t worry, I will be quick from now on
The ‘With’ Association
The ‘hasandbelongstomany’ relationship has been one of the most confusing aspects of model relationship in CakePHP for quite sometime, but (hopefully) not anymore. The ‘with’ association is here to make life easier. So what is it? It is nothing more than an easy way to access the join table. With the ‘with tag’, you can directly access the join table without any hassle. Some of the details are discussed by Chris’ Brain in A Glimpse Inside CakePHP 1.2
Making RSS Feeds for your app cant get easier. Super-easy RSS feeds with CakePHP 1.2 by Jiri Kupiainen and How Easy Are Web Services in CakePHP 1.2? Really Easy! by Chris Hartjes explains it all. Don’t forget to go through the comments.
In CakePHP 1.1, pagination was not present in the core. With 1.2, pagination is right at home as Rob Conner explains in Basic Pagination Overview (1.2) and Advanced Pagination (1.2). Update(30/08/07): I cant believe I missed this wonderful article by Nate: Pagination, etc.
Authentication and ACL
Authentication and Access Control List are explained in the following bakery articles:
Now with helpers. There is a new helper called FormHelper that is dedicated to you know what(Forms). Also, now the “dot” notation can be used(Model.field instead of Model/field). The links below shows the usage of different helpers in 1.2
- Html Helper by Jeff Keith
- Form Helper
- Update(30/08/07): Form Building: More Auto-Magic Than You Can Handle? by Nate
The 1.2 Manual
Ok! Thats it! But before I let you go I have one final link. I am sure you are eagerly waiting for the 1.2 Manual to come out. The CakePHP people are hard at work to get it done. But, if you want to have a sneak peak at the work, just click here. It is still incomplete, but going through it will not harm.
Thats all I have. I plan to write more about each 1.2 features in more detail, but lets see how that one goes. If you think I missed any useful link, please do let me know. I will be glad to update.