RSS
 
18. Oct. 2011

More great news: CakePHP 2.0 stable is out!

18 Oct

After 1.5 years of development, Cake catches up with other frameworks.
It is now as modern as most of the others while remaining the most powerful of all.
Almost none if its automatic got lost during the process of rewriting.

Some of the important aspects of 2.0

  • Faster (20-40% depending on the application)
  • Modern (>=PHP5.2 and state of the art functionality)
  • More Flexible and extensible (almost every class can be switched out with own ones)
  • Exceptions as error handling
  • PHPUnit as test suite
  • Hundreds of fixes which had to stay in 1.3 due to compatibility issues
  • Lots of enhancements and new functionality like “aliasing” – details

If you start a new project dive right into 2.0. That’s the future 🙂

For all those who like to assimilate the changes as online video:
tv.cakephp.org/video/CakeFoundation/2011/10/06/ch-ch-anges_cakephp_2_0_-_by_mark_story

Radical changes

There will be radical changes. For once the file names now match the class names. This needs quite some getting used to, but once you do, you wouldn’t want it any other way.
Also, the framework paths changed to allow more customization and overwriting.

In 1.3 the normal cake setup was:

/app/
/plugins/
/vendors/
/cake/

In 2.x it’s now:

/app/
/plugins/
/vendors/
/lib/Cake/

You can overwrite (=replace) any core class just by putting the file (using the same path/package structure) in your APP/Lib/ folder:
APP/Lib/Routing/Router.php replaces the core one, for example.

Tips for upgrading to 2.x

The migration guide will help to upgrade existing applications to the new version.
This will be quite a bit of work, though. Almost all classes are renamed, many methods and object variables have been dropped.

Your biggest help will be the cake shell script "ugrade" which is available in 2.0 now. It helps you to automatically upgrade some of the code. You can either select all or single tasks like renaming components etc.
Simply type "cake upgrade" in the console to list all available methods.
It really is a huge time safer. You should backup or commit everything before you attempt to run this script, though.

The basic steps:

  • Switch out the core first (in /lib/Cake)
  • Check what is working so far
  • Use the guide to fix the issues piece by piece until everything is working again

UPDATE:
I tried to upgrade a medium sized 1.3 app to 2.0. After finding several problems I opened a ticket.
Hopefully the upgrade process will be made smoother the next couple of weeks 🙂

Also read about some more upgrade tips on my new post here.

Last Words

I am a little bit proud to see many of my tickets and proposed changes/fixes being now part of the framework.
Contributing to such a popular and large framework is sometimes easier than one might think. Sometimes it needed only hours to approve one of my tickets. OK, sometimes it needs months.
Providing a good reason and attaching proposed changes as diff or patch can really speed up things and should encourage you to involve yourself in cake core development, as well.

0.00 avg. rating (0% score) - 0 votes
 
2 Comments

Posted by Mark in CakePHP

 

Tags: , , ,

Leave a Reply

Tip:
If you need to post a piece of code use {code type=php}...{/code}.
Allowed types are "php", "mysql", "html", "js", "css".

Please do not escape your post (leave all ", <, > and & as they are!). If you have encoded characters and need to reverse ("decode") it, you can do that here!
 

 
  1. Luís Armando

    October 20, 2011 at 01:57

    Good explanations.

    I’m thinking of migrating a system I am developing and is currently online. I think this system is pretty big, something like 20 controllers/models, also some components, behaviors and even two datasources.

    When I do that I’ll post my experience in this process of migration to cake 2.0.

    Please, keep posting about your experiences.

    Nice job in this blog.
    Grüße.

     
  2. Mark

    October 20, 2011 at 12:25

    right now I am working on some enhancements for the upgrade shell. see the above ticket link for details.