Feb 7, 2008

A Code Igniter Review

UPDATE (Jan. 21, 2010): This review is almost two years old, which is a long time in the web world. It represents what Code Igniter was like 2 years ago, not what it might be like now. Try it out for yourself to see if you like it.

As usual, I will randomly post articles about stuff that has nothing to do with Ubuntu. This is one of those.

Recently for a work project I used a PHP framework called Code Igniter. It is designed to make your life as a coder easier while at the same time keeping a good amount of speed (compare this to other frameworks like Rails, which are slow behemoths).
Does it achieve this? Well since the project isn't completely done we haven't gotten to test the speed, but in terms of productivity I believe we actually lost time. We had used a small framework before that was whipped together by one of our programmers in half a day. His framework was very fast and very simple. Although it didn't to any automagic or URL routing or any of that junk, it was enough for us to implement a rudimentary MVC structure to keep things maintainable.

What is wrong with Code Igniter you may ask? Well it seems like it is fast because it strips out so much stuff for you. By default there is no support for a layout template in which your views are embedded (although a quick Google brings us to this), and models must be manually loaded. They don't connect to the DB automatically, so you must also do this. Therefore, you must also close the DB connection. Our programmer who was working on that part didn't realize it since our old framework would just open the DB connection at the start and close it at the end, we didn't have to include it in the controllers. So we ended up running out of available DB connections during development.

We have come to the conclusion that Code Igniter can draw a parallel to programming languages. Regular PHP programming is like using assembly or FORTRAN, it is very unstructured and spaghetti-like. Code Igniter is like using C, you have some structure but the system does absolutely nothing for you. Then other frameworks like Rails are like Ruby, you just worry about making the stuff and the framework handles the nasty details for you.

All-in-all, I feel that Code Igniter does not give you much productivity gain that you can't get by just arranging your code in an MVC structure. If you want a framework, you're better off with Symfony or Cake, or if you want to scrap PHP altogether (which I really want to do but work won't let me) you can use Rails or Merb.

UPDATE(05/14/2008): This post was written over a year ago, which is centuries in the open-source web world. I would not be surprised in the slightest that my points above are no longer valid, and that Code Igniter has become a much nicer framework. It would be better if you looked into it yourself and make a judgment call.
Unfortunately I doubt I will be updating this post for the newer version of Code Igniter as I have completely dropped PHP in favour of Ruby or Python based systems and will not likely be starting any projects written in PHP in the future, nor working at a PHP job.

3 comments:

Mike Peters said...

Loved your review

We were considering CodeIgniter for a standalone project and were on the fence.

Your review helped make the call that it's not worth it at this point in time

Would be too much of an overkill and it's not the "holy grail" we've been looking for


All the best,
MP

Rob Britton said...

@MP: To be fair, I wrote this review a long time ago (at least in terms of web/open-source). I don't know if a lot of my points are still valid or not.
In any case, it also depends on what you're doing. If Code Igniter has become a more mature framework since I wrote this post, it would be much better to use it than to attempt to write your own framework or to write an app in just plain PHP.

Also remember that there are no "holy grails" in software development ;)

Alexa said...

I've used CI for 2 of my projects, and I must say, being an absolute PHP noob just 5 months ago, this framework has allowed me to increase my skills and create very efficient applications. Despite the learning curve (what framework doesn't have one?) I feel like CI lessened my development time - it made tasks that I used to spend quite a while thinking about and putting together, into writing just a controller and view, and model if I want to interact with that database. The built in form validation library is my favorite!