CodeIgniter vs. CakePHP

I almost fear putting this kind of post together as it's bound to pull the fanatics (in the negative sense of the word) out of the woodworks. Right off the bat, let me just say that I've tried to be as fair and honest in this assessment and I've tried to keep it just to the facts while interjecting what my preferences are.

I'm 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.

Why compare these two?

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.

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). CodeIgniter supports regular expressions for routing, whereas you'll have to wait until CakePHP 1.2 for that feature. Correction: CakePHP 1.1 supports regular expression for routing but it's not detailed in the manual and is getting updated in 1.2.

They both support Scaffolding which is an automated way of generating a view based on the model. Scaffolding is meant for simple prototyping and CodeIgniter takes it a step further by requiring a keyword in the URL to even access the scaffolding. I'm guessing one could omit the keyword, leaving this feature essentially optional. I prefer not to have to use the keyword as I sometimes build personal projects not intended for public eyes and using a keyword would be a nuisance.

And the list goes on...

Approach to Simplicity

I believe 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. Everything is in plain sight and you can really see how things work.

CakePHP's simplicity comes via automation (euphemistically referred to as "automagic"). It makes the coding process quicker but harder to figure out "what is going on" without popping your head into the core. For me, I like to understand how everything works and I've had to poke around under the hood more than once. For people just getting started, things probably look a little daunting.

Working with Models

CodeIgniter's model handling is fairly straightfoward and basically allows you to mimic a standard SQL query with a few straightforward commands like these examples:

$query = $this->db->getwhere('mytable', array(id => $id), $limit, $offset);

$this->db->select('title')->from('mytable')->where('id', $id)->limit(10, 20);
$query = $this->db->get();

Note: the method chaining in the second part of this example is only available in PHP5.

You can also create a model object, load it in and build custom methods to handle a custom task. You'd want to do this in the model and not the controller to help isolate code into the MVC silos.

CakePHP takes a slightly different route by automatically loading in the model that matches the current controller (controllers tend to be named similarly to the models they are associated with). You can turn off this automated loading and even assign different models that should be loaded by the controller instead.

CakePHP also takes things further by establishing all the model associations for you, allowing for some really easy querying. For example, assuming I'm in a controller named post_controller, I could do the following:

$this->Post->Comment->findAllByPostId($id)

I chose this particular query because it shows two different concepts. The first is the fact that I can access the Comment model via the Post model (assuming I've defined that association in the Post model). The second is the fact that I have a method called findAllByPostId. CakePHP allows records to be grabbed via findByX and findAllByX queries where X is equal to the field name you're trying to find.

Where I think Cake shines is in its ability to pull in all associated data automatically. Take the following query as an example:

$this->Post->findById($id)

This query would automatically pull in all the comments associated with this Post. Really handy stuff.

Validation

When working with models, you'll inevitably have to handle data validation. Data validation in CodeIgniter is handled via a validation class. A set of rules get defined and assigned to the validation object. The validation object automatically (I assume) validates the data passed via the URL or form. From there, you can decide how that gets handled. 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. The first uses a single test against each field defined in a validate variable declared in the model. This works okay for simple stuff but it quickly becomes a cumbrance. Beyond simple validation, I take advantage of the beforeSave callback to perform any custom validation, invalidating any fields that fail.

It's a toss up for me as to which one "wins". CakePHP 1.2 will have its validation system reworked a bit to allow for more flexibility.

Views

CakePHP handles this fairly well by using a default layout (which you can easily switch at runtime). The layout has two variables be default: title_for_layout and content_for_layout. Each action automatically links to a particular view which gets spat into place. Again, it's the "automagic" approach. As long as you name your files a specific way, controllers automatically get linked to models and views. It's easy enough to override all of this, too, and define your own layouts or view files. There's no convenient way to get the generated view data, however, making custom built caching mechanisms difficult to implement.

CodeIgniter takes a very straightforward approach: like include files, almost. Each file gets loaded in and processed. There's a templating class but it doesn't simplify things much beyond the built-in view handling. You can mimic the CakePHP approach by always including the header and footer calls but it's not as seamless. CodeIgniter offers hooks allowing view and caching mechanisms to be overridden and replaced with a custom system.

Out of the Box Features

CodeIgniter in my mind wins this hands down with classes for FTP, Email, File Uploading, XMLRPC, Zip encoding and more.

CakePHP on the flip side comes pretty light but tries to make up for it using the Bakery. You can, like CodeIgniter, easily drop in 3rd party classes for any features you might need. Interestingly, although I haven't tried it, you could probably drop in many of the CI classes into CakePHP without issue.

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. However, you can fine tune things at the controller level using any of the controller-level callbacks (beforeFilter, afterFilter and beforeRender). Things like auto-loading helpers and components can also be specified easily at the individual controller level.

CodeIgniter allows for the auto-loading of helpers, libraries and plugins but does this application-wide.

Documentation

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 really going much beyond what the API offers. Because of the format of the original documentation, you can also get it in other formats such as CHM and PDF. CakePHP has the Bakery which contains user-submitted articles, components, etc. The dev team also hangs out heavily on the IRC channel (#cakephp at irc.freenode.net). Finally, there's the CakePHP Google Group which is pretty active.

Final Verdict

I'm a pretty pragmatic individual and I honestly feel 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.

I'm still personally a fan of CakePHP over CodeIgniter for much of the "automagic" that I mentioned. And it's shortcomings have been getting addressed with each new iteration (1.2 will be a considerable leap over 1.1 but it will still be awhile before it's released).

Notes

This comparison was based on the documentation for CodeIgniter 1.5.2 and having used CakePHP 1.1. I have specifically avoided the subject of performance due to the amount of time required to design, develop and test such a thing.

Published March 18, 2007
Categorized as PHP
Short URL: https://snook.ca/s/782

Conversation

75 Comments · RSS feed
David Hemphill said on March 18, 2007

That's a nice analysis of the frameworks. Sounds similar to the conversation you and I had at the mt party.

Some thoughts:
I'm not sure I like having the model auto-loaded for me, but I suppose that's just a minor gripe.

You probably knew this, but Code Igniter allows you to auto-load libraries, plugins, and helpers on a controller level. It's not just limited to application-wide.

I looked at Cake first when I was shopping around for frameworks, but found CodeIgniter's documentation and out of the box functionality to be the best fit for me. That doesn't make it the best by any means. Cake seems like a good system all around.

Eric said on March 18, 2007

Great article, I would like to see a thorough review of Zend over Cake or CI, our office uses CI now, but I believe Zend will eventually be the de facto standard with all it's corporate backing?

Anyhow a Zend vs. Cake vs. CI vs. Symfony would be cool, hell I'd probably pay for such a study.

Jonathan Snook said on March 18, 2007

@David: I'd be interested to hear how libraries, etc can be loaded at the controller level as that didn't seem documented very well.

The auto-loading is nice because 9 times out of 10, you need it anyway. For those times you don't need the model, you can turn off the auto-loading.

@Eric: the problem with something of that scope is that it gets harder and harder to make straightforward comparisons; especially since people are always looking for different things from different frameworks. CI and Cake have more in common making it easier to compare.

dan said on March 19, 2007

Just skimming the codeigniter documentation I dont see any functionality to associate models?

I hate the implementation in cakephp:

$hasMany = array...

It is butt ugly code in my book... PHP frameworks is not the way for me to go... Thats for sure :)

Joel Moss said on March 19, 2007

@dan: Its not cake code that is ugly. Its PHP that is the ugly one. Although, thats not to say that Cakes code cannot be improved.

If I had to choose a PHP framework, it would be Cake, with Symfony following closely.

Ahsan said on March 19, 2007

Wow! Exactly what I was looking for.

I am from the Cake camp, to start with, but recently the CI fire was attracting me a lot. So, I thought I would take a look. What staggered me is the similarities between the two frameworks. Being comfortable with Cake, getting hold of CI wasn't that difficult at all. One thing that CI is missing is the layout features we have in Cake. To be honest, it was disappointing not to have the cool layout feature in CI.

But when in comes to speed, Cake is no match to CI. If you are planning for a high-load site, CI will surely be the better performer.

Matthew Pennell said on March 19, 2007

@Jon: You can autoload stuff at the individual controller level by including the $this->load statement in the constructor of the controller class.

I'm a big fan of Code Igniter, and based my decision (I looked at Cake also) almost entirely on the quality of the documentation. The introductory screencasts and the offline version of the user guide make CI much more welcoming than I found CakePHP to be.

Kenzie said on March 19, 2007

The straightforward approach, great documentation and lack of constraints is exactly why I chose CodeIgniter.

For CI, in a controller you can: $this->load->library() (or model or etc) in the controller's constructor, or any individual function.

Andre said on March 19, 2007

To shorten it up: to me CI is simpler and more intuitive, while Cake is a little bit harder to learn, maybe, but definitely more powerful.

I'm loving each one of them for different reasons: CI because its syntax it's easy to remember ($this->load->whatever() is just great), plus it has amazing libraries and helpers; CakePHP is great for table associations (that save a LOT of the programmer's time).

I'm using them for two separate projects, so I still have to make up my mind in a definitive way.

In the end, while I still consider CakePHP a more solid framework, I like very much Code Igniter and its documentation, which is way better organized than Cake's, but I have to say that I would prefer to have more written tutorials, not only screencasts.

They're both winners, anyway.

@Ahsan: You might want to look here for a CI layout system that's very similar to Cake's. ;-)

Derek Allard said on March 19, 2007

Well written, fair and concise. Good job Jonathan. I'm a CI developer employed by EllisLab. I've used both frameworks, but am obviously a CI devotee.

To answer your question "I'd be interested to hear how libraries, etc can be loaded at the controller level as that didn't seem documented very well.". Autoloading is done via an "autoload.php" configuration file. Here is an example of autoloading a model.

$autoload['libraries'] = array('database', 'email');

It's been mentioned, but Cake does have a stronger database associations model. There have been nice community contributions to do this in CI, but currently it is one of those "out of the box" features we're lacking.

I'd also mention community, and corporate support. My experience in the Cake community was positive, but I was primarily involved during Cake's infancy, when things were constantly changing and even documented code didn't work. Since then I've poked back in, and I find Cake users as a whole to be smart, reasoned and helpful. CodeIgniter shares all of positive traits, but also as an "underdog" has built up a "brothers in arms" type of feel around it. It is rare that a post for help goes more then a few hours without a response, and I've seen total strangers write entire libraries for anonymous posters just to help them out. It is frankly, staggering. CodeIgniter also benefits from its association with EllisLab. While I know Cake isn't going anywhere soon, CodeIgniter has the intellectual, financial, and community resources of a successful web company behind it, with decades of "development years" and millions of installations behind it.

Thanks again for a great comparison. I think open source wins, PHP wins, and the web wins by having access to both of these amazing frameworks.

dan said on March 19, 2007

Joel - I know that php's syntax is part of the sinner...

However in my book cake's implementation to the rails conversions is the biggest sinner...

I love rails - but I dont find cakephp very appealing...

Maybe I should take a look at symfoni which as far as I understand is php5 only.

Pierre said on March 19, 2007

Thanks for this review. Your article and the comments helped me getting a better picture of each framework.

If I can add my two cents about Symphony (I was in a seminar about it a few days ago), the lead developer strongly recommend using it in a dedicated hosting environment with a PHP accelerator. If you're looking for a "lightweight" solution, this is clearly not the one. And personally, I think it is way too complex (very abstract) to use.

I have been working with Cake for a few projects, but being an intermediate programmer, I heavily rely on documention and tutorials and this is not Cake's strongest point (but the community is really great and helpful).

Nate K said on March 19, 2007

Nice comparisons of the frameworks. As others have said, both are excellent frameworks. It took me a while to really settle on one (Cake), due to all of the great features in both.

I am looking forward to the 1.2 release of Cake. I have been developing with it just to get used to it, but it still has its kinks and daily changes. Validation in the models is much better, giving more options and flexibility. Forms are much easier to generate as well.

The one thing I find annoying at this point is that all tags generated are xHTML - even if you specify your doctype to be HTML4 Strict. I have written something to switch it accordingly, but it would be nice to see something like this in the core. This may sound tiny, but for some bigger projects and using the Cake API to generate forms, tags, etc - it can be a little rough.

RE: Dan
It is really tough to come from RoR to PHP, syntax wise. I have several friends who went from PHP to RoR and never looked back (cursing PHP all the way). Personally, I don't mind it - but its a matter of preference. I don't think it is Cake that is bad though (remember, they are still supporting 4/5).

Jonathan Snook said on March 19, 2007

@Ahsan: while some stuff I've seen on performance comparisons have shown CI to be faster, I find that Cake is fast enough. For example, I've had a couple front-page digg's and my site (on Dreamhost) has handled it just fine. (Most WordPress users don't seem to be able to share the same success.) Sure, we can talk performance but I think you have to be careful in considering fast vs faster and what's simply fast enough.

@Pennel, Kenzie: duh, the constructor. Makes perfect sense! I'm surprised that wasn't really covered in the documentation (unless I missed it).

Stephen Lounsbury said on March 19, 2007

Great article, Jonathan! I haven't tried CI, but I'm curious about it as being a Cake user I have heard CI mentioned more than once.

About you surviving the front page digg's, do you use any of Cake's built in caching to help handle the higher load?

@Nate: About making the helpers generate tags as HTML instead of XHTML, you can change that by editing tags.ini.php. See Snook's post here.

Mark said on March 19, 2007

Great overview. Thanks for the followup, Jonathan.

Medyk said on March 19, 2007

One important thing:
Code Igniter is procedural and Cake is object oriented (while still limited by php4 support which doesn't have real object programming support).
Anyway it's all about what programmer you are. If you're beginner then CI will be much easier to gasp for you.. if you're more experienced and fan of OOP then definitely Cake will be more serious framework for you.

Jonathan Snook said on March 19, 2007

@Stephen: I've taken advantage of the model caching but that's it. I probably should hop in and re-enable the view caching which I disabled during testing of theming I had been doing at the time.

Chris said on March 19, 2007

For me its same as Andre said! Love both frameworks, even when startup in Cake is worse but for larger projects its ORM rocks. The CodeIgniter Community is simply one of the best, friendliest and very active I ever met. This is a powerful reason for CI.

However, the more I dive into Rails, the less I am looking back to PHP world.

Vinch said on March 19, 2007

Thanks ! I was waiting for something like this for a long long time !

Steve Oliveira said on March 19, 2007

I agree with Medyk. Cake is more OOP than CI, however both are very powerful frameworks and frankly this is one of the great things about PHP and open source. You have options. Neither are as good a RoR but they're getting there.

Grim Reaper said on March 19, 2007

Very interesting comparison, and RoR interests me too.
I'm just curious - and probably a little OT...
Is RoR in the same ballpark for speed/server load capacity?

Nate K said on March 20, 2007

RE: Stephen
I was able to edit the tags in 1.1, but have had a few issues editing the same in the most recent 1.2 release.

My hope was that if you were using the HTML helper to generate the doctype, that depending on what you selected - the rest of your tags would be compliant with either HTML/XHTML. Just as Snook said in the article you pointed to, I am more than happy to use HTML versus XHTML with an incorrect mime type. I can do the HTML just as strict as XHTML, XHTML just enforces it more....

Nate Abele said on March 20, 2007

dan:

What's wrong with:

var $hasMany = 'Comment';

??

Nate Abele said on March 20, 2007

Nate K:

It is actually a pretty simple matter to drop a separate tag def in your app/config folder to replace the tags that get generated.

Pierre said on March 20, 2007

Found this article where Cake, Ci and Symphony performance are compared:
http://www.sellersrank.com/php/cakephp-codeigniter-benchmark/

Scott said on March 21, 2007

Medyk: Code Igniter is not procedural. The entire framework is OOP and you are forced (with the exception of helpers and plugins) to adopt the OOP paradigm in your applications. Controllers, Models, etc., are all classes.

Nuno Mira said on March 21, 2007

I started with Cake and I found it really difficult to understand and confusing.
Documentation is very poor so, if it's the first framework you get your hands on, you'll have a hard time and become frustrated.

Then I moved to CI whose documentation is very good.
This is a big helper. Almost everything is there, simple and clear.

I really can't say compare anything else about the two, because I'm only familiar with CI now.
It was easy and fun to learn, and a there's a great community around it.

Maybe I'll try Cake again and I'll be able to understand it more easily now that I'm familiar with CI.

Hasin Hayder said on March 22, 2007

I personally started with Cake but it seems so difficult to cope up with that. CI come with excellent documentation and libraries, agree with you snook, but the thing you said about autoloading, I find it more flexible at controller level.

More over, using the configuration file, you can autoload any helper, library, model at global scope. Not limited to any specific controller.

@Ahsan, I extended the controller of CI and created some hooks which will add the layout feature in CI. You can either check CI forum or my log for that.

One more thing you probably missed John, CI has very short learning curve unlike Cake.

CI rocks!!

Md Emran Hasan said on March 22, 2007

I am another one like Hasin here. I was really very impressed with CakePHP in the beginning. But I am not very fond of things getting down "automatically". Knowing my code's ins and outs is a major issue for me.

I had real difficulties deploying a cake site in my shared hosting, whereas CI give me abs 0 headache in this matter.

And the libraries and documentation of CI is second to none in this arena.

However, Cake's model was the most helpful thing. I am currently porting that idea in CI and will release that hopefully in a week :)

And btw, CI rockssss !!!

Fredrik said on March 22, 2007

Neat, you managed to compare to frameworks without acctually turning it into a flamewar :).

I'm becoming fairly comfortable with Cake and currently launching a very simple webiste using it, and constructing two larger ones using it. Previously I mostly used a homegrown little system based on a Data Object Pattern, however it grew out of my hands so I had tow switch. Oh well, enough about me.

I sat down with CI on a weekend, I've read all the hype and performance tests. However, as I sat there replicating my Cake App, I noticed two things:

  • Lack of/Less strict conventions. IMHO, this is where Rails and Cake shines. I've ditched ASP.NET because of it. I could make my own, but unless I document properly (as if), chances are I'll forget it when I decide to change something. Forced conventions are good.
  • A slight performance hype. CI doesn't autoload the things that Cake does in a basic set-up. One issue I've pondered with Cake is that it ranks somewhat in the middle during performance tests. CI ranks higher. And when I loaded my first views into the browser it rendered pretty fast according to the debug messages. However, after starting to load all the components and helpers the rendertime made it roughly as fast as CakePHP on my local WAMP server (which I use for development).

Personally I'm sticking to CakePHP. Frameworks are a matter of productivity. I'm productive with cake. And that's what matters for me right now, IMHO. And really, it's what should matter to anyone.

dan said on March 23, 2007

Nate Abele:
I find it butt ugly...

As Nate K. also writes it is PHP that is not as expressive as ruby...

Had I implemented something like Rails in php I would have done it much more "PHP-like" instead of emulating every bit that cant be done as elegant as in ruby because of the nature of the language...

Sergey Leinweber said on March 23, 2007

Thanks for a great review of the frameworks. I have to make a choice for an MVC framework in a proof-of-concept project.

It seems like two frameworks are mature enough and I'll try to use one of them in a fairly complex system with a lot of redundancy in their 8 letters tables.

I've tried to start using Zend Framework but it lacks some basic examples and its API doc are sometimes confusing. You read something only to face the fact that the new beta is out :(

Jose Lozano said on March 25, 2007

I have used both, and definitely I prefer CodeIgniter because it is really easy to use.

Dustin Weber said on March 29, 2007

I have a friend who is a CI self-proclaimed "expert". He was always preaching about it, so I gave it a try. After looking it over for a weekend, and practicing a bit, I was not convinced. I was already down the CakePHP route anyway, but in the end, he couldn't convince me CI was better in any significant way. In fact the long-term drawbacks (limitations) seemed insurmountable.

I can't help but admit that they do work/look very similar.. but once you dig in, the similarities end quickly.

The most important thing to me though, is an active community. Working with a something that is constantly evolving like these frameworks, requires a very active community.

They both seem to have nice, helpful, and large communities going for them, but... Googling "codeigniter" yields 536,000 results while Googling "CakePHP" yields 3,170,000 results. That is a significant difference that tells you a lot about long-term viability (IMHO).

I wrote a series of writeups on my blog about CakePHP and my search for the "best" framework. They might be worth reading for anyone on the fence.

- Dustin Weber

Woody Gilk said on March 30, 2007

I've never used Cake, but have been using CI since August 2006. As someone who knew PHP rather well, but had never used a framework, I was drawn to CI's excellent documentation. Neither Cake or Symfony had great docs, and neither seemed to be as straight forward to me.

The main thing I like about CI is that it's extremely easy to shape and mould it to fit whatever type of website you are creating. It's fast and easy to write libraries for CI, and easy to create wrappers around external code. Although I think you may be right about CI being more a "beginners" framework, it scales very nicely for experienced programmers.

Scott said on April 16, 2007

Akelos is supposed to be the RoR for PHP4/5
it looks promising, i would like to see it compared to others too:
www.bermi.org/projects/akelos_framework
www.akelos.org

kos said on May 07, 2007

CakePHP advantage:
-better plugin setup
- take recursive as far as you want on any association
- Deletes for HABTM, hasMany, and hasOne
- Request Component
- Ajax edit in place and slider control

Vang said on June 21, 2007

Sure cake is great but the superior documentation of CI can speed up development much. What good is saving 10 minutes of coding if you have to spend 30 minutes trying to figure out how cake is supposed to work?

Convention over configuration is better when it's simple and documented and you have a few sample sites to fool around with. Unfortunately cake is missing that.

Baz L said on July 02, 2007

I can sum things up pretty simply:

I have a friend. He introduced me to CI and PHP Frameworks in general. He's been working for a PHP company using their own framework for over a year. He favors CI because "it gives you more control..." blah blah blah. He's a guy that likes to do things himself.

I'm an "on the side" PHP developer. Just testing at first I was drawn to Cake. After finding this site, I was leaning more towards Cake. After viewing this: http://www.cakephp.org/screencasts/view/1
I was hooked. I mean, I'm still trying to pull my jaw up from the floor. Yeah yeah I know RoR's been doing this for years. But I didn't know that, and we're not comparing those two. I'm sorry. I'm a lazy dude. If it can do it for me and I patch things on the side, I'm all for it. I was never up for reinventing the wheel.

Some things in Cake are a bit clunky if you ask me, but I believe that it makes up for it with all that it does for me.

If CI decides to implement something like the bake.php in Cake, I'd be willing to give them another look.

uzma khan said on July 13, 2007

Well, if there is no good documentation then how do you expect someone to be able to understand all the advanced features you mentioned??

CakePHP has to work on proper documentation and I honestly think they have to simplify the way this framework works ... its just too hard for a newbie to understand Cake

Shahryar Ghazi said on July 13, 2007

I agree to the above.. Cake is hard to understand but when you understand it everything makes sense

I also agree that Cake community needs to work hard on proper documentation and user guides coz the manual is simply not well written.

Anyways, I am waiting for "Cake/CI vs Symphony" as well

thanks for this

kobdesign said on July 17, 2007

Thank you for this Now, I interest CI because i begining PHP Framework and Cake hard for me.

kost said on July 25, 2007

Thank you for this comparsion.

I think, I'll prefer CodeIgniter because it is better documentated.

Paul said on July 26, 2007

My Take

I wrote up about this too and agree with your points. I think the main advantage of CakePHP lies in its handling of models and associations. They're just so powerful if you use them correctly. Good post.

Guillaume said on August 09, 2007

I'm working on a few big projects, one in particular that has over 100 tables, most of them with 10,000's of rows and a few with millions of rows. They're not really high-traffic sites (they're mostly intranets), luckily.

Obviously with such large datasets, most queries are highly optimized for their specific usage. Many queries touching the same tables can look different depending on what columns are being extracted. We do a lot of reporting, this is also another place where tricks are used to gain speed. Since se use all sort of tricks to make them fast, so obviously using the built-in query generators ($this->load() or whatever) in most (all?) frameworks.

How much of a pain is it to build your own queries in many places, and does it defeat the purpose of having a framework? I've looked at CakePHP and while it seems powerful, too much magic is going on. And very often, the tables are already created when I get a project handed over... so convention over configuration would not really apply in my case (I don't always have the control on the table/field names).

Anyway I'm simply looking for advice since I'm tired of having 150,000 of lines to manage on that project. Life would be so much easier if we would have a framework!!!!

Stopofeger said on August 10, 2007

I also tried cake first, then tried CI found it good then tried cake again and found it amaizing. It is what should be a rapid application framework. It has so many cool stuffs. Many people have said praised many features such as associations etc. But I think it's the over all organisation that makes cake so much better. I never "got stuck" at anything. There is something for every problem. Its like they have thought of everything when coding it. The documentation is a problem. But cake is for serious customers not for rookies so this hardship is justified. But after you grasp cake, there is no going back to CI for sure. I wonder why no one mentioned bake. It is one of the best thing in cake. It feels so good to create the db and define the association, then just fire up bake script and almost 50% of your work is done. You just have to do the tweekings and you have an rapidly developped apps. I think CI is good. But what CI does can be done with even joomla. A RAD should be a RAD just like cake. You have sense of magic when using cake but not in CI. Also the user base also matters. Cake has so many "working" projects around. Ranging from OS projects to commercial projects. Being a freelancer, I have got many clients asking to develop their apps in cake not in CI. So it is shining where it really "matters". Guess what, even mambo will be using cake. This shows its commitment that an established and widely used cms like mambo will be using cake. I belive CI is good at the begining. But if someone is really looking for rails like experience, and want to use it in real projects then cake is the best option.

Seandy said on August 13, 2007

For the first time, i decided to use a php framework, prado was the point, but it was hard for me to learn, so i gave up.

Second choice was CakePHP. When i read the manual, i said "what is it?", i was very confuse, so i took a look to CI and started to watch the blog tutorial video, just in time i could write codes. CI's Documentation is great.

And then i tried to go back to CakePHP after i found how frameworks works. Step by step, i understand about CakePHP flow. It is very impressive. I like a lot about Model Associations. Everything makes sense.

So finally, i choose CakePHP for my web developement.
If you found difficult to understand CakePHP, try CI first, and then try CakePHP and i swear, you'll never look back!

Namaless said on August 13, 2007

I choose CakePHP because if choose Mambo it, cake is good project :)

For italian people: Italian Comunity.

Bye bye.

Andho said on September 06, 2007

i was also looking for my first mvc framework and CI hit the spot. Its just easier to learn when you need to do things fast. But its not really what i want.
Now im thinking about checking out a new framework. maybe Cake or Zend.

Like to know more about rails. Does it has support from web hosts as much as php?

William said on September 17, 2007

Rails is very slow and not recommended! You might try Django, which is well documented, but has no books in print. Django is much, much faster than Rails. Rails makes development a pain in the rear, because each test takes forever to run. You can not only do a coffee break while the test is running, you can go out and have a two-martini lunch! And each release is slower than the last. Don't ask me where all these fanboys came from, but it has much more to do with Ruby than with Rails. Ruby itself is elegant.

I use CI occasionally, and it's very nice. Also quite fast.

Marnen Laibow-Koser said on September 21, 2007

I have used Fusebox for all my PHP projects to date (I came from the ColdFusion side of things, where Fusebox is quite well established, so it was an easy switch). I'm currently starting a new project, and I'd like to use a more OO style of development, which CI seems to support very well. I love CI's documentation too -- among the best I've seen on any open-source project. Cake, by contrast, looked hard to understand and unimpressive, at least from their website.

It will be interesting to see how it goes. I'll post again if I have anything new to say about this...

Logan said on September 29, 2007

CodeIgniter is lightweight, faster and better documented. CakePHP is bloated and slower. When I looked at choosing a framework, it seemed like CodeIgniter was the clear winner.

Jonathan Snook said on September 29, 2007

@Logan what version of CakePHP were you looking at? What kind of benchmarks did you get between the two frameworks? How do you define bloated? By lines of code or number of features? It really depends what you're looking for.

Marnen Laibow-Koser said on October 02, 2007

An update: CI's approach to unit testing was a little anemic, and I wanted to play with TDD on this project in addition to some other things...so I went through several other frameworks and finally settled on Ruby on Rails. There's a lot to learn here, but I can always use a few new skills. :)

Lee said on October 04, 2007

I'm still on the fence in deciding which framework to use. I've never used a framework before so I am leaning toward CodeIgniter. I have a new project to start, and it's relatively small, and probably would be perfect for CI. But, I don't want to get down the road a few months, and regret not going with Cake from the start because of it's increased DB automagic. It's tough to go back and refactor an application using an entirely different framework. Decisions, decisions...

Shane said on October 04, 2007

I use CI. I never even bothered to try Cake because I was immediately put off by the documentation, or lack thereof. As well, CI doesn't make assumptions about how I ought to implement my application. I am more inclined to write my own ORM layer for CI before giving Cake a shot.

GreatArticleThankYou said on October 05, 2007

Performance Showdown, any thoughts? Please provide feedback:

1. Zend Framework.
2. CodeIgnitor.
3. Symfony. // This is Yahoo Bookmarks.
4. CakePHP.

(Also, how are PEAR's classes compared to Zend's classes?)

ADthanksVANCE

Daniel Errante said on October 08, 2007

Both have their benefits, but I use CodeIgniter because of its heavy documentation, simple learning curve, out-of-the-box features, security, and video tutorials! CakePHP seems like a great framework also but CodeIgniter sold me with the tutorial videos.

Jim said on October 12, 2007

Google results appears to have shifted. March 29th, CI had 17% of the Cake search results. Now "CodeIgniter" yielded 1,460,000 and "CakePHP" yielded 5,890,000 search results. CI now has 25% of the Cake search results. The difference a few short months can make.

>They both seem to have nice, helpful, and large communities going for them, but... >Googling "codeigniter" yields 536,000 results while Googling "CakePHP" yields >3,170,000 results. That is a significant difference that tells you a lot about long-term viability (IMHO).

Setti said on October 21, 2007
Junal said on November 05, 2007

Excellent article! was looking for something like this. i don't understand why Cake can not have a better documentation or CI can not have better models associations.

Nice comparison snook !

osman said on September 05, 2008

There is no reason to use CI instead of my own library. CI is missing same essential classes like ACL etc. But cake or zend fr have very rich tools than CI.

Plus, yes CI is very easy to learn because there is more less things to learn :) If a framework provide more tool, you have to spend more time to learn each tool. If you dont need any tool. why do you use a framework...

Plus, CI and ZF are depend on their commercial company (ellislab, zend). This is negative point. Cakephp is belong to only its community.

its very funny to read some subjective benchmarks. There is not importand speed differences between these frameworks. if want build most fast web application. why do you use a framework... :) if you say CI is faster than cake, I will say you that pure php is very very faster than CI. If speed is most importand thik for you should not use any framework.

bazet said on September 08, 2008

can CI do magics like generateTreeList() ? ( MPTT solution by Cake ) and built in MPTT ACL ?

Julien said on October 23, 2008

I was using CakePHP for my day-job, but now that i'm going freelance i consider learning another framework, and right now i'm learning CI. A lot of things are very familiar to me, such as routes, helpers, controller, views, etc. But so far, i think that the Cake's top advantage is the out-of-the-box model association features (habtm, hasmany, hasone...) which increases the development speed for applications that requires a lot of such associations (but you have to optimize it in order to avoid the huge overhead). So if, like me you are not an SQL guru, but you're willing to learn a RoR-php-clone, try Cake. And if you keep struggling with the doc, there are some nice books on the subject (like : Beginning CakePHP, from novice to professionnal).

@osman : For me, both development speed and runtime speed is important. Using a fast framework is a tradeoff, but a convenient one. This is what Rapid application development is all about.

Son Nguyen said on December 16, 2008

I just started reading about these frameworks lately (Cake, CI, Symphony, ZF) as an alternative to our in-house framework and gotta say Cake has many cool ideas but some (many) of its syntax and conventions are really ugly and unintuitive.

It should also take advantage of the magic operators in PHP5 (__autoload, __set, __get) much sooner than Cake2. I guess I could use some of their ideas with our in-house framework instead of porting 50,000+ lines over a new framework. For now, we'll learn the best practices and wait for Cake2.

Lancelot said on January 16, 2009

Good afternoon. As long as you derive inner help and comfort from anything, keep it.
I am from France and now teach English, please tell me whether I wrote the following sentence: "This is a video page from multimedia english classroom where learning authentic english is fun."

Thank you very much ;-). Lancelot.

Jamie said on January 29, 2009

I love cakephp for it's strictness over codignitor. Codignitor also lacks the bake features.

new coder said on February 10, 2009

I read both cakephp and CI book..yes whole books(i cannot say poor documentation now..) so after then ..i found cakephp is really big brother of CI.....
Actually later no there may be something called CI...I personally feel it should be mergered....
They are very similar now.....
every thing that can be done in CI can be done in cakephp...they are very similar and when i read it as two frameworks i some times feel that they are kidding...
i suggest people who say to make app in codeigniter to do it in phpcake rather...and they agree...

rassel said on February 12, 2011

hello u guys.... i am just starting on frameworks could u guys pls. suggest me which one would be good for me as a starter....
i know basic php5, javascript, jason.....

Josh, UK said on March 05, 2011

@Rassel, make sure you know the OOP coding methodology before you try and learn a framework as it will help alot!

hartcrareecorty said on March 11, 2011

Arts, entertainment, publishing
hartcrareecit981

frank said on March 19, 2011

something amazing about this article is the fact that CI still lacks of an Auth class

Shinya Koizumi said on April 20, 2011

I have used to framework called Qcode( http://www.qcodo.com/ ) and cakephp.

Here are the list of stuff I didn't like about Cakephp.

I don't like the query response to be array. It could be just me but just can't remember the key name ( especially for people whos mother tangues is not English like me ) whereas if it was returning array of classes i can just use the auto-complete feature of IDE.

Cakephp can't host multiple sites or at least not easy to do.

Cakephp has command line tool to generate model, view, controll classes based on tables you have in the database and make the relationship for each models, but you can't really use to update the relationship otherwise it will have to write over to the existing ones.

radhe said on May 18, 2011

I have used both framework. Both are too good. But i think CAKEPHP is best.

Sorry, comments are closed for this post. If you have any further questions or comments, feel free to send them to me directly.