Comparing CodeIgniter, & CakePHP
Posted by Surya kant - over 11 yearsago
In the market large number of framework and CMS tool available for the PHP. And also every framework and CMS have own value. For the now we discuss two of them CakePHP and CodeIgniter both are great frameworks in their own rights. They each have their pros and cons which I will cover here.
CakePHP The idea behind Cake was to make developing applications fast (ie, “convention over configuration”) by cutting down on how much code the developer needed to write. Less time working means more time making money.
Pros
- ORM is the best option to communication with database. ORM solves the problem of SQL injection, so they are very popular between programmers. It is also makes SQL query simple and you can fetch (for example) a blog post and all of its comments in one or two lines of code.
- Reverse routing. This makes maintaining links in an application so much easier. This means if you change a controller’s name at some point, instead of search/replacing 200 instances of “admin/foo” with the new “admin/bar” (and hoping you didn’t miss one) you simply update the route in one place. Any links using the reverse route array will automatically point to the right spot at runtime.
- There are big resources available on internet for the CakePHP. CakePHP site have also a good documentation , you can find tutorial from the IBM site too. CakePHP is old framework and it’s popularity creates number of user, that can give easy solution of your problem.
- Plugins. This makes re-using code super simple and help keep the app folder clean.
Cons
- Incredibly slow. Recent versions of Cake (2.2.x as of this post) are much faster and more efficient than previous versions, but it is still one of the slowest frameworks. I am personally not sure how well it holds up when an app of it gets slammed with tons of hits. I am aware that Mozilla’s plugin site runs on an (old) version of Cake, as does Cake’s own bakery and Q&A sites, which all seem to run fine. I suspect it’s a balance between caching and server fine-tuning.
- TONS of lines of code. Some developers don’t care what’s going on under the hood; I like to be able to quickly find out how/why something works the way it does. The code is well documented but there’s just so much of it. it can be overwhelming.
- Occasionally, you need to use code to reign in just how much it does. For example, my first step is to open my App Model and set $recursive = -1 and adding Containable to Behaviours to prevent it from auto-grabbing related models and letting me tell it what I need.
- Autoloading can be awkward. In recent versions of Cake they’ve introduced lazy loading in the form of App::uses. Then, if you need to have access to (for example) the Model class, you do something like App::users(‘Model’, ‘Data/Model’) at the top of the file. This is, IMO, clumsy and no better than doing a require CORE_PATH.Data/Model/Model.php;
Conclusion: Personally, I use Cake if I need to put together a dynamic site quickly that I don’t foresee getting a lot of hits (like for a local restaurant, for example).
CodeIgniter I’ve mentioned on here before that CI was the first framework I ever used and helped me finally understand the concept of OO programming. It’s certainly popular, and has been around a similar amount of time as Cake.
Pros
- Super easy to set up and use. This makes the entry level for a newer PHP developer much lower.
- Extremely well-documented, with examples in a lot of places to illustrate usage.
- Extremely fast.
- Huge community. As with Cake, since CI has been around so long you can almost always find your answer via Google, CI forums, or their IRC channel. This also means there’s lots of code contribution to help get things done (like Paypal libraries, etc)
- Sparks the “hub” where CI packages go to hang out and be used.
- Lots of the tool in the market that provide auto code generation and also some provide CI as readymade CMS tool some of them are PyroCMS, Ionizecms, Pisyek, bonfire , CRUD generator
Cons
- No modular separation by default. This is a big deal for me as I prefer keeping my code as separated as possible. There is Modular Extensions, which does the job, but I’ve never been 100% satisfied with it.
- Since 2.x broke CI has been 5.1.6+ for its minimum PHP version, but the whole $this->library, procedural function helpers, and extending a class by prefixing MY_ in front of it way of doing things just doesn’t work well for me. Perhaps this will change in 3.0? *shrugs*
- I personally have to extend way too many core files to get CI working the way I like it. The more you modify the core, the more you have to maintain later. I’d rather be coding something productive.
Conclusion: CodeIgniter is a fantastic framework for getting the hang of PHP and OO coding and for knocking a small site together fairly quickly with low overhead.
|
|