. Updated Daily. Editions SDA India   SDA Indonesia
JAX Asia 2008 - Conference for Enterprise Java, SOA, Spring, Web Services, Ajax, Agile and more
BUSINESS ENTERPRISE SOLUTIONS ARCHITECTURE INFORMATION SECURITY WIRELESS & MOBILITY DATA & STORAGE DEVELOPMENT HARDWARE













News

Wednesday, 21 March 2007

Codeigniter Versus CakePHP

 

 

Jonathan Snook in a post over his blog does an assessment of Codeigniter and CakePHP. He says, he is pitting these two frameworks against each other but there really isn't a clear winner. Each has its strengths and weaknesses and ultimately falls to what your preference for certain features might be.

He explains his statement under the following heads:

Why Compare These Two?

He says CakePHP and CodeIgniter are quite similar in their approach on a number of things, including their support for PHP4. Any mention of one inevitably leads to someone mentioning the other.

He states some similarities like the following:

  • They both attempt to create an MVC architecture, which simply means they separate the (data) Model from the Controller (which pulls data from the model to give to the view) from the View (what the user sees).
  • They both use Routing which takes a URL and maps it to a particular function within a controller (CakePHP calls these actions).
  • They both support Scaffolding which is an automated way of generating a view based on the model.

Approach to Simplicity

He believes much of CodeIgniter's appeal is its simplicity in its approach. Most of the work is done in the controller, loading in libraries, getting data from the model, and pulling in the view. However CakePHP's simplicity comes via automation. He points out a drawback that though it makes the coding process quicker but it becomes harder to figure out ‘what is going on’ until you divulge into the core. He says, it’s a bit daunting for beginners.

Working with Models

He finds out that CodeIgniter's model handling is straightforward and allows you to mimic a standard SQL query with a few commands. But in CakePHP, he says, it takes a slightly different route by loading in the model that matches the current controller. You can turn off this automated loading and even assign different models that should be loaded by the controller instead.

Validation

When working with models, you'll have to handle data validation, he says. Data validation in CodeIgniter is handled via a validation class. A set of rules get defined and assigned to the validation object. He assumes that the validation object validates the data passed via the URL or form. The validation class can also help automate some of the process of setting error messages for specific fields.

CakePHP handles its validation through the model itself in one of two ways, he informs. The first uses a single test against each field defined in a validate variable declared in the model. This process works for simple stuff but it becomes a cumbrance, he thinks. Beyond simple validation, he takes advantage of the beforeSave callback to perform any custom validation, invalidating any fields that fail.

Views

CakePHP handles this well by using a default layout, which you can switch at runtime. The layout has two variables be default—title_for_layout and content_for_layout. Each action links to a particular view, which gets into place, he says.

CodeIgniter takes a straightforward approach he says. Each file gets loaded in and processed. There's a templating class but it doesn't simplify things beyond the built-in view handling, he observes.

Out of the Box Features

He says, CodeIgniter wins this hands down with classes for FTP, E-mail, File Uploading, XMLRPC, Zip encoding and more. CakePHP on the other hand does not boast of too many features but tries to make up for it using the Bakery.

Auto-loading

CakePHP allows for application-wide changes to be done via the base application controller that all other controllers inherit from. Likewise, you can create global model methods using the application model file, he says. CodeIgniter allows for the auto-loading of helpers, libraries and plugins but does this application-wise.

Documentation

He says Documentation is key to understanding any framework well enough to develop within it.

CodeIgniter has a complete list of all components with each method and property documented within. CI also has forums and a wiki, which feature a lot of user-submitted code.

CakePHP, on the other hand, isn't as well organized. The manual is starting to show its age with some sections not going beyond what the Application Programming Interface(API) offers. This format of the original documentation helps you to get it in other formats such as CHM and PDF. CakePHP has the Bakery, which contains user-submitted articles, components, etc. Finally, there's the CakePHP Google Group, which is active.

Final Verdict

He says, he feels that these two frameworks have a lot going for them. They take a much simpler approach to application development than the complexity that is something like Symfony.

But personally, he says, he is a fan of CakePHP over CodeIgniter for the ‘automagic’ function. He adds that it's shortcomings have been getting addressed with each new iteration.

 

Read the Post

 

Related Reading: Overview of Code Igniter

 
 
print save email comment

print

save

email

comment

 
 

Search SDA Asia

Free eNewsletter

SDA Asia Magazine Free Download
 
 
 
Copyright @ 2008 SDA Asia Magazine - All Right Reserved Privacy Policy | Terms of Use