Skip to main content

10 reasons to choose cakephp

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 aboutAutocomplete 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

Comments

  1. Used for one of the project. Didn't give me "wow" experience like I got from Zend or Symphony.
    Project was deployed on initial version of CakePHP (~1.2). Scaling and Performance sucks on CakePHP. I don't know about the state of current version.

    If you have have high traffic application, sure you can prefer with CakePHP.

    They have tried to clone RoR. But not proper cloning. It's PHP not Ruby.

    ReplyDelete

Post a Comment

Popular posts from this blog

UpComing Features in PHP 5.3

Namespaces A subject touched and trialed many times in PHP, namespaces. This feature has been responsible for the longest discussions on PHP-DEV, but finally a consensus has arrived on how this is going to work. The biggest benefit namespaces will provide is shortening of long classnames. To make sure that your class libraries can plug into foreign code, it has always been recommended to prefix your classes, for example "Zend_DB_Connection". This can however lead to very long names. Namespaces fixes this by grouping classes together. The full-on classname becomes Zend::DB:Connection, and by placing 'use Zend::DB' on top of your code, the 'Connection' class can be referenced with just that name. Example: // The class file namespace Zend :: DB ; class Connection { function foo () { echo 'bar' ; } } ?> require 'Zend/DB/Connection.php' ; use Zend :: DB :: Connection ; $connection = new Connection (); $connection -> foo (); ?

Install PHP 5.3.0/Lighttpd On Debian (Lenny) With Imap, MySQL, Sqlite3 And ImageMagick Support

Install PHP 5.3.0/Lighttpd On Debian (Lenny) With Imap, MySQL, Sqlite3 And ImageMagick Support This tutorial covers the setup of PHP 5.3.0/Lighttpd on Debian (lenny) with imap, mysql, mysqli, sqlite3, ImageMagick and mycrypt support. For this tutorial I will assume you are logged in as root this is not advised. First we need to install the webserver: aptitude install lighttpd Now we install the packages needed for mysql and mysqli support. You will be promoted to enter a mysql root password - please use a strong password. aptitude install mysql-server mysql-client libmysqlclient15-dev Next install some packages php needs to compile. aptitude install libtidy-dev curl libcurl4-openssl-dev libcurl3 libcurl3-gnutls zlib1g zlib1g-dev libxslt1-dev libzip-dev libzip1 libxml2 libsnmp-base libsnmp15 libxml2-dev libsnmp-dev libjpeg62 libjpeg62-dev libpng12-0 libpng12-dev zlib1g zlib1g-dev libfreetype6 libfreetype6-dev libbz2-dev libxpm-dev libmcrypt-dev libmcrypt4 sqlite3 bzip2 build-essential l

Zend Framework WebServices

REST Web Services use service-specific XML formats. These ad-hoc standards mean that the manner for accessing a REST web service is different for each service. REST web services typically use URL parameters (GET data) or path information for requesting data and POST data for sending data. Zend Framework provides both Client and Server capabilities, which, when used together allow for a much more "local" interface experience via virtual object property access. The Server component features automatic exposition of functions and classes using a meaningful and simple XML format. When accessing these services using the Client, it is possible to easily retrieve the return data from the remote call. Should you wish to use the client with a non-Zend_Rest_Server based service, it will still provide easier data access. In addition to Zend_Rest_Server and