10 reasons to choose CakePHP as Framework
January 14th, 2011 by Pavanesh SoniTwo 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.
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.
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.
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.
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.
I will be glad to hear your opinion about them.