Clients often ask me to recommend a PHP-based MVC framework, so I’ve spent some time evaluating some of the more popular ones. There are dozens now, but two of the early ones are still very popular: CakePHP and CodeIgniter. This isn’t meant to be a super in-depth review, just a quick comparison of some of the strengths and weaknesses of each. I’ll admit upfront that I’m biased in favor of CakePHP. After evaluating them both, I decided I liked it better and I’ve been using it heavily for the last several years. So if you think I’m being unfair below, please let me know in the comments!
CodeIgniter is a pretty loose MVC framework. It’s not quite just a collection of libraries, but it doesn’t have the strict adherence to the MVC pattern that CakePHP does. In general, CI will let you break the rules pretty easily, while CakePHP makes it harder. The end result in my experience is that I see a lot more poorly architected code written in CI than in CakePHP. CI just makes it too tempting to be sloppy and cut corners, but ends up costing you more in the long run. On the other hand, learning and using CakePHP won’t automatically make you a good developer, just like using CI won’t make you a bad developer. In fact, if you’re a great developer, CI might be a good choice because you have the experience to know what rules to break. However, if you’re reading this comparison right now, you might not quite be there yet.
Ease of Use
CodeIgniter doesn’t do as much of the magic for you behind the scenes like CakePHP does. For those new to MVC or even new to programming, this can be comforting, because you know what to expect. However, once you learn the CakePHP way of doing things, you can fly through projects. And when the automagic way of doing things isn’t working, you can always override it and do it your own way. This is what makes rapid development so fun in CakePHP: you can build your prototype or version 1 using the built-in automagic dust that CakePHP provides, and then swap out what you need to later as your project matures.
CakePHP is slow. Not super-dog-slow, but it’s quite a bit slower than CI. This is a big concern for some folks, and if you’re one of them, then you should weigh this more heavily. I almost never worry about this, for several reasons. First, a lot of that slowness won’t be the bottleneck in your application. Your database is far more likely to be the bottleneck than your application is. And you can do a lot with some simple caching and scaling methods to speed up your app.
But more importantly, hardware is pretty cheap. Developers, on the other hand, are not. In my opinion, if you’re building something that you’re not 100% sure will experience heavy load, don’t pre-optimize. Get it out there ASAP and let people start pounding on it. You can always throw more hardware at the problem if it’s a success. That’s not to say you should ignore scalability completely or ignore best practices in performance, but I wouldn’t make it your primary focus.
Documentation and Community
Eighteen months ago, I would have easily given the edge here to CI, but the CakePHP community has matured a lot over the last year or two, and the documentation situation has improved drastically. Today, my assessment is that both communities are very strong, with lots of good folks in both camps writing documentation, plugins, modules, and other enhancements to their frameworks. You’ll find great people no matter which path you choose.
As I admitted at the beginning of this comparison, I’m biased in favor of CakePHP. It’s true that you do give up some advantages in speed, and you’re also forced to adhere more to the MVC pattern than you might be comfortable with, but in my experience, CakePHP lets developers write cleaner code and do it faster than they would if they were using CodeIgniter. You might pay a small hit in performance, but hardware is usually cheaper than developers. Regardless of which you choose, just pick one and build something awesome.