My experience with CodeIgniter
On this last Sunday I didn’t go to Lake Tahoe or Yosemite National Park. I stayed at home working as a consultant to a company that wanted to have i18n on their website. They asked me to make it possible to easily have the text files available for a third party to translate them.
The website itself was written in PHP with the templating engine Smarty. Since the website is also going through a face lift I decided to take the chance and update the ancient code structure to CodeIgniter, making it more clean and avoiding the hassle of using gettext (CodeIgniter has a pretty decent i18n functionality). CodeIgniter is a MVC PHP framework trying to mimic Rails, which is a good thing, since Rails is a proven technology.
Making the story short, CodeIgniter is a huge achievement in the PHP world. It takes the tedious and painful task of developing a PHP website from scratch to a somewhat more pleasant activity. Being a MVC framework, it decently separates the models (usually representing a database table structure) from the controllers (responsible for handling the HTTP requests and answering them) and the views (that actually contain HTML and hopefully no logic). It provides some of the Rails nifties like the Helpers.
Still, it does not even come close to Rails. The routes file actually needs the help of an .htaccess file to work properly if you want to do more fancy stuff (like removing index.php from the URI). If you want to have a constructor on your Controller you need to explicitly call the parent constructor. Small thing, but it gets in your way. Including images or any other file always requires appending the root url. Fortunately, CodeIgniter has a useful function called (base_url()) that you have to append each time you want to include an image. Two problems with this: 1) repeated and annoying code (ie, base_url() appended to every img src attribute); 2) Having to change the base_url setting on the config file if you change the website. There are a couple more things that I don’t remember right now but I’ll comeback as I keep delving through the framework.
All in all, it’s a pretty decent framework and it’s way better than developing a PHP website from scratch. It still has to eat a lot of spinach to come close to Rails but, on the other hand, it doesn’t get on your way which is always a great thing. By the way, using i18n was a breeze. So my piece of advice would be that if you’re doing PHP development you should take a close look at it. For more serious stuff, there’s always the Zend framework.




I haven’t tried CodeIgniter but I use symfony, also a MVC PHP Framework, for a long time now and just love it.
Give it a try.
I’ve been using it for sometime and I agree, it lack some features, but it’s still quite amazing. If there’s one thing it beats RoR is that the large majority of webhost still don’t support RoR. :)
Hi Mário,
If you want something closer to Ruby on Rails you should have a look to the Akelos Framework and give it a try on your next project.
Check the video and you’ll see how Railish it is. Plus it comes with internationalization support built in.
Andre and Bermi,
Thanks for the hints, I’ll certainly try those out!
If you are looking for a PHP framework you should really try Symfony. Read here: http://www.symfony-project.com/weblog/2007/06/11/is-symfony-too-slow-for-real-world-usage.html
The limitations mentioned when comparing CodeIgniter to Rails really seem very small/irrelevant. Also, they seem to largely compensate for the ultra small footprint of CI.
Having experience on both frameworks, can you comment on other more significant limitations of CodeIgniter? DB mappings? Form validate? AJAX integration?
Thanks!
Joao S,
I haven’t delved that deep into CodeIgniter to be able to fully compare both frameworks, at least to the same extent that I’ve used Rails.
There is a guy having used Rails, has taken the time to post a comparison of PHP Frameworks that mimic RoR. Check it out at http://www-users.mat.uni.torun.pl/~tomahawk/summary.php
Bermi,
Akelos seems like a fantastic option!
Great job!
CodeIgniter is the greatest one. Just by watching the video I can learn this framework, and I am try to get used to it.
And now I think I love this CI Framework.
You should try it. Believe me.