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 Pattern – Model 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.
Pingback: developercast.com » Nik Chankov’s Blog:
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.
@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 π
@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
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.
@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/.
I prefer CodeIgniter….
I believe Code Igniter do all that stuff, but is so much lighter and fast.
And yes, easy to understand.
@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).
Pingback: napyfab:blog» Blog Archive » links for 2007-10-17
@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.
Pingback: The Magic of 10 « FlashColony Blog
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.
Pingback: rascunho » Blog Archive » links for 2007-10-29
Hi All,
I am looking for a PHP/Cake Developer guru in London for a contract. If you are available or know anyone that might be, please could you ask them to contact me or send me an e mail to natasha.baden@explorerec.com
Thank you,
Natasha
I am choosing cakephp after reading your article. Please provide me guidance about which book is best for cakePhp.
I have the same question as adguru. Is there any training institute for cakephp?
One reason NOT to choose it: CakePHP Development Team’s attitude is simply terrible towards anyone who points out something wrong about their framework or who doesn’t do exactly what they said.
A few people have experienced this, including myself:
http://www.h3rald.com/blog/42
http://www.h3rald.com/blog/too-many-cooks-take-2
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.
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.
Although the post is quite old, you are right the community if also important point in the list! π
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
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.
Code Igniter blows.
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???
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.
@nik thanks great help so i need to avoid $this->Model->query() in application.
right???
Yep. Depends how complicated is your application though.
cake is best choice for all developer for develop any type for application. there is no boundation.
I started one project in CakePHP and it is really good framework But I feel some problem with making customised URLs.
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
hello dears can you help me in cakephp 3.2 for image upload and it on database and fetch image or file path from database….please reply me ..my gmail id is mandeepkhaleriya.08@gmail.com….
What is the Operation and application of CakePhp?
CakePHP is a popular open-source framework which offers a fast application development process to enterprises. CakePHP helps the businesses to reach highly robust and specialized websites by following the simple procedure. However, there are numerous PHP frameworks easily accessible in the market, but CakePHP has made its place among the profoundly deemed web development platforms offered in the market.
As we know CakePHP is playing a great role in web app development
What makes your point great is that it’s not just a regular point. It’s a point that makes the reader think. It’s a point that’s backed up by great quotes or statistics.
Wow! I love this page that pops up after I commented. Excellent idea!!