Initial Thoughts on the Codeigniter PHP Framework
For the past few weeks i have been working with the CodeIgniter framework for a large scale project at work, the system is a project management application that allows different levels of users to login and track projects that belong to them. My first experience of a PHP framework was the wonderful CakePHP and my exposure to that MVC framework helped me greatly when using CodeIgniter. In this article I'm going to go through a few pro's and con's of CodeIgniter coming entirely from a perspective of a CakePHP user.
Initial Setup and Documentation
Getting started with CodeIgniter is extremely easy, after downloading the zip file and creating a virtual host to use with Xampp I had the main page up and running without any serious issues. This was all done by looking at the extensive and well documented user manual, you can access the user guide both online and offline (a copy is shipped with the downloadable zip file for offline use) and it contains pretty much everything you need to know about CodeIgniter.
The user guide is quite a refreshing change from the CakePHP manual which only currently covers the 1.1 version and it's rather old and outdated. All the CodeIgniter classes are fully explained with working examples along with the helper functions. Most of my time has been spent looking at the Database class reference and the form helper guides for quickly creating forms for user input and are a great help for newbies getting to grips with the syntax of the framework.
The CodeIgniter Forum and Community
A great supplement to the online user guide is the CodeIgniter forum, and I can safely say that it is the most comprehensive and friendly online communities you could wish for. Help is on hand for pretty much any issue you may be having and even clueless, complete beginners asking for help are not ridiculed and exiled like other online communities.
The forum is also frequently visited by the creators of CodeIgniter which makes the community even more appealing as your questions and answers are sometimes coming from the actual people who built it. Overall the forum is an excellent place to ask for advice and other programming frameworks need to wise up about the potential of having an active, friendly, central place to deal with their users.
Classes and Helpers
The classes and helpers at your disposal when using CodeIgniter are both extremely useful and easy to extend and develop. Similarly to CakePHP the classes are used by Controllers and Helpers are used in the view. It took me a while to become familiar with the new syntax and class names but that's really a non-issue when using something new. The database class in particular is well documented with the Active Record Database Pattern making it easy to connect to the database and retrieve your information.
The main helper that I have been using is the form helper and it does an excellent job of saving time when creating forms. I also extended and created my own helpers without too much hassle, of course this was after reading the manual and checking the forums for people with similar problems.
A Lightweight Framework
CodeIgniter is touted as a framework with a small footprint and that's easy and elegant to use. I cant really argue with that as I've managed to use CodeIgniter without any major problems. The framework is also easy to pick up and use without any restrictions on database naming conventions or names for Controllers and Models unlike CakePHP which will be welcome to any beginner getting started with the framework.
Overall if your relatively new to PHP programming and with using a framework then CodeIgniter is probably the best place to start. Its easy to install, use and the guide along with the amazing community will be able to help with any issue you may be having.
Problems with CodeIgniter
Although I have been very positive about the framework as a whole, it does have some drawbacks. The first major issue with the framework is how it deals with retrieving and manipulating data from the database. The project that I have been using CodeIgniter with consists of many database tables that are all related, for example 'users' in the system have many 'projects'. With CakePHP I could simply use one of the many magic methods to query a user from the database and automatically retrieve all their projects. This makes dealing with your data an absolute breeze and its the main reason I use a framework in the first place, to make things easier. In CodeIgniter I basically have to create the entire SQL statement every single time data is retrieved or saved to the database. Granted it does take care of the major security concerns such as SQL injection and Cross Site Scripting vulnerabilities but I don't think its enough.
Another frustration I came across when using the framework is how it deals with form validation, it does have some nice features such as the callback functions and the way you can apply normal PHP functions such as trim() and md5() to the form data on the fly. The process to re-populate a form when editing an item is quite obscure and I had to hunt down the solution in the forum as the user guide does not show a correct way of doing things. Form validation is a large part of any online PHP application and with this framework its quite cumbersome to achieve.
After using CodeIgniter for a few weeks I am quite impressed, the user guide and community forums are just superb for beginners getting to grips with a new framework and the lax restrictions imposed on the programmer make it quite easy to pick up and start using straight away unlike CakePHP which has quite a steep learning curve. On the other hand because I actually spent the time and effort working with CakePHP I got to know and understand the framework better and it actually improved my programming skills on the whole because the conventions being used are spot on.
In conclusion I am not going to be switching to the CodeIgniter framework for all my projects, CakePHP is simply too good at dealing with data and the inbuilt "bake" script can get the skeleton structure of a complex application up and running very quickly. Here are a few other articles I found comparing the two frameworks:
Posted on 28th March 2008