10 reasons to choose CakePHP as Framework

Two months ago I wrote about benefits of Community Frameworks compared with Home-Grown ones. In the article I mentioned some of the benefits of Cake, but it was “scratching the surface” rather than complete info.
Here I want to list all those things, but near to each of them I will give short explanation what is it and how CakePHP implement it.

So, if somebody ask me what are those 10 things which drive me to choose this framework as my primary one I will answer with:

MVC PatternModel support data handling, with model class you can insert, update, delete or read the data from the database. View support data rendering on the screen. Controller process and responds to events and can modify data before it interact with the model (database). With this pattern it’s very easy to separate the logic from the presentation, which is very useful for large applications and sites. How is in CakePHP? It is MVC Driven framework, so you cannot do much if you don’t use this pattern. I found it really handy once you start thinking MVC way.

ORM – Object Relational Mapping is a programming technique for converting data between incompatible type systems in databases and object-oriented programming languages /scarry huh?/. With simple words this mean, that every table is represented from a class. In these classes you can define relations between other tables, validation definition and also you can predefine specific callbacks especially for that table. The most important thing for me is the relation definitions, because once they are properly defined you can have sub records /from the related tables/ without doing anything specific – you just have them when you get the main record. This one I find as extremely helpful. I had some projects in which I didn’t wrote a single line of SQL.

Proper class inheritance – Cake has two main folders in each project. First one is the core lib /cake/, where I prefer only to watch, but not to touch /just like peep show/. The second folder is the Application specific one /app/. These days I read an article “inheritance is evil” and the author is probably partly right, but in CakePHP inheritance is very sensible and understandable. All Application specific controllers extend AppController class which is empty, but can be extended with some extra logic or there you can predefine some core functions which you want in specific way. The same apply to Models which extends AppModel where you can predefine for example deletion instead to delete a record to mark it only as deleted with a flag etc. With these two classes you can change almost everything you want.

Easily extend with Components, Helpers, Behaviours and Plug-ins – This point is very important for me, because it allow us to create parts of reusable code which is very helpful for more than one project. Rather than extend Cake’s core libraries, special functionality can be placed in components, helpers, behaviours and a combination of Models, Views and Controllers encapsulated as Plug-ins – this way you can modularize your projects.
There are a lot of plug-ins helpers and components in CakeForge site, so you don’t need to write everything from the scratch.

Zero configuration – In CakePHP there isn’t single part of code /configuration/ where you need to specify the location of the library or the url of the site – everything is auto-detect and the only thing you need to care about is the Database connection settings.

Build in validation – When I start coding with Cake the validation was really basic /at least that’s what I saw in the tutorials and articles/, but now it become really useful feature where you could attach multiple advanced validation rules to single field. I have some ideas for Ajax validation which I would share in a new article later on.

Ajax support – There is Ajax helper class in the core lib which you could use in various ways – form submit through Ajax, Event observer or build in Autocomplete. I have an article about Autocomplete with ID=>Value relation which you can take a look. CakePHP uses Ajax with Prototype and Scriptaculous.

ACL Functionality and Security – CakePHP has build in Authorization and Security. There are many articles explaining the ACL logic, the one in the Cake Manual is very useful.

CRUD scaffolding – CRUD come from Create, Read, Update, Delete – these are the main activities in most of web applications. It is extremely helpful, because with one single line of code you can see preliminary view of your application. In cake core lib there was bake.php, now becoming /console/cake. With this script is very easy to be “produced” all models, controllers and views and after that they could be modified for the specific requirements of the application. I really like that feature and I am using it every time when I start new application – saves a lot of time.

Ability to create tests – This so far is not my favourite feature, but I would really want to use it in the future. Cake provide ability to create tests which will help you to check the critical points in your applications. There are core tests, as well as custom ones, which you can build your own. It’s handy when you build a large application where some parts are critical and the performance should be checked carefully.

There are also other great features in CakePHP which I didn’t mention, but the article is for the top 10 of them.
I will be glad to hear your opinion about them.

Share it:
  • Facebook
  • Twitter
  • Digg
  • StumbleUpon
  • del.icio.us
  • Google Bookmarks
  • Yahoo! Buzz
  • Add to favorites
  • Identi.ca

32 thoughts on “10 reasons to choose CakePHP as Framework

  1. Pingback: developercast.com » Nik Chankov’s Blog:

  2. Hehe, of all that list, there’s nothing in there that symfony doesn’t do (and IMO, symfony does it better).

    But then again, I’m biased toward symfony.

    I guess, when I saw the headline for this article, I was hoping for ‘what CakePHP does different’ – everything on this list is pretty much what I’d expect as standard in a framework.

  3. @all – thanks for your comments.
    @Joshua – About which framework is better I think the best framework is this one which you know best. The same is with Developer tools :)

  4. @Joshua – agreed but I have been following CakePHP as well as Symfony since a long long time and have always felt that CakePHP showed a simpler way to do the same things as compared to Symfony

  5. Before I made a choice for a framework to start using, I’ve compared Cake and symfony. Both are very similar I think. symfony actually does just about anything in your list. Except for the fact that Cake is PHP4, and symfony is PHP5.

    I don’t want to be negative about Cake, because I think it’s a good framework. But the fact that Cake is PHP4 actually made me decide to go with symfony.

  6. @Stefan – strange, I read such thing in a week or two ago in IT forum, but it’s not true.

    Cake is possible to be used in PHP4 and PHP5, that’s why I like it too it’s portable. There are things like __constructor in code and they didnt limit the visibility of the classes and functions, just because it’s still could be used with PHP4. I think it’s pretty easy to be “restricted” this way, but I dont see the point.

    By the way, I am working with Cake only on PHP5 /as my development enviroment/ and deplay the application some times on PHP4 without any problem so far /Production enviroment are not my responcibility so I don’t care/.

  7. I believe Code Igniter do all that stuff, but is so much lighter and fast.
    And yes, easy to understand.

  8. @Nik: But it says PHP4, and so can not use some of the useful features of PHP5. Once you start using PHP5-only features, it will break on PHP4. And thats a shame. And PHP4 compatibility in this day is a bit useless, with the EOL announced and all.

    Even while maybe some PHP5 stuff like __construct() are used here and there in the code doesn’t make the code PHP5. It’s maybe compatible with both versions, but since it doesn’t break PHP4 backwards compatible code, it is and stays PHP4 code (written with PHP5 forward compatibility in mind).

  9. Pingback: napyfab:blog» Blog Archive » links for 2007-10-17

  10. @all – thanks for your comments and arguments

    @Stefan – I coundn’t say that I am expert in Symfony – not at all, I tried to follow the “First Project” example from the Framework site it was several months ago, but I find it extremely difficult to follow. You have to store data config in yml files, then validation in another file, then to follow and execute 1000 different commands in order to produce some simple interface. And instead of changing db /by adding fields from phpMyAdmin/ I have to browse the yml files and to start learning new sintax how to define field in YML. To tell you the truth with the first article I get tired.

    Probably I should put in top of the article “The simplicity is the most important in my decision” as first thing :)

    But anyway arduing which framework is best is the same like arguing which football team is better – every one has his own favourite. I understand this and I respect all your opinions, but and at the end the client is the one who will use the system wont care on which language or on which version has been writen – for him it’s just important to be operational and working.

  11. Pingback: The Magic of 10 « FlashColony Blog

  12. Has anyone heard when CAKE will add a full-blown PHP5 version? Since PHP4 has an EOL I’m sure the bakers are planning something.

  13. Pingback: rascunho » Blog Archive » links for 2007-10-29

  14. Pingback: 10 reasons to choose CakePHP as Framework

  15. I personally prefer CakePHP, its easier to setup. I tried to use symfony and after 2 hours I still barely understood how the while structure is, the frontend and backend etc.. the tutorials on their website doesnt explain and the whole structure and hence its really a pain. They just ask you to execute a bunch of commands which is painfully hard to remember. Hence, I have gone back to Cake.

  16. After first impession I choose cakePHP. I will admit that my final two frameworks were between symphony and cakePHP. Zend was too loose, and did not have the complete structure as code ignitor, symphony and cake. Code ignitor was an attractive option because it appeared to be easily understood and was super light weight compared to other frameworks but I was turned off that it did not have an ACL system built with it in which I was planning to use extensively in my current project. The top 10 reasons to choose cake are all good points to choose a framework but my number one reason which made me seperate cake from symphony was community support, which deserves to be on the list. Symphony I found hard to configure at first and there is not a strong community to help guide you. Maybe if I was more patient with symphony I would find symphony better than Cake. Both cake and symphony upon review seem very similar I bet someone experienced with both frameworks would say they both can do the same thing the other could do with just different variations. At the end of the day when I had problems with symphony and looked at their docu
    entation and then typed it in google I was left stumped in real world scenarios it is unrealistic to cease a project for 3 weeks so you can learn a framework.

  17. I have just been at Cake PHP’s comunity – and asking some critical questions, which would normally would lead to flames – and have found out the community (or at least the portion of it I saw :)tpl0ch, teknoid and many others) is extremely friendly.

    That’s a very important point in favor :) I will from now on use Cake.

    Cheers!
    Droope

  18. An interesting posting, full of opinions, however we stuck with Cake for most of the reasons you have given. However it should be noted that actually Symphony is better, although it does have quite a steep learning curve like Zend Framework.

  19. is cakePHP’s ORM cross database compatible???
    ie., i need to develop a application which is compatible for atleast postgreSQL,MySQL and MSSql. is it possible to migrate into different database by only changing the driver parameter???

  20. Theoretically it’s possible. But this wont be possible if you have used custom SQLs in the app.

    If everything is so simple and uses Cake’s native Model functions for me there is no problem to switch between databases with a change of a datasource name. :)

    Further more, you can mix the datasources so 2 different types of database can run in one application.

  21. I need a website and mobile app for all OS n tab with
    Ruby on Rails something which cld be a copy of tastespotting.com / supercook.com / foodpair.com
    Compulsory registration from all possible social networking sites Users should be able to register any how in any which way possible, by a standard email process OR through social networking sites like FACEBOOK TWITTER LINKEDiN PINTEREST and all such sites also if possible Registration through mobile phone shld be made available.
    Mobile Apps shld not have much of a difference than the main site.

    International Payment Gateway shld be user friendly with emphasis on internet banking and any visa master or gift n all possible debit cards and could be added with IMPS.

    The Recipe Management and Socializing Application shld allow registered users to view unique recipes of other individuals who are passionate about cooking.

    HOWEVER the recipe management application shld only allow cooking enthusiasts to share edit existing recipes and repost and promote recipes by email they would like others to prepare and enjoy with their friend and families – ONLY if they make specific payments.

    Regards
    Kishor
    khhk1628@gmail.com

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>