Fabulous PHP frameworks: CodeIgniter


Become An Insider

Sign up now and get free access to hundreds of Insider articles, guides, reviews, interviews, blogs, and other premium content from the best tech brands on the Internet: CIO, CSO, Computerworld, InfoWorld, IT World and Network World Learn more.

CodeIgniter combines an easy installation with simplicity and flexibility, but is limited in features compared to competitors

CodeIgniter, a PHP MVC (model view controller) framework sponsored by Ellis Labs, touts itself as a solution for those developers who eschew large, over-abundant frameworks. CodeIgniter's installation requires little effort; you unzip the download package to your Web application's home directory and modify a pair of files -- one a general configuration file, the other governing database specifications. CodeIgniter needs only PHP version 4.3.2 or later. (The CodeIgniter engineers decided not to require PHP 5, because they did not want to alienate current users already employing PHP 4.) Perhaps CodeIgniter's only downside is its lack of JavaScript support, although this is expected in a future release.

Like the Zend Framework, CodeIgniter uses the front-end controller pattern. All HTTP requests are received by index.php, sent to the proper processing routines through a routing system, passed through a security system (which shields the application's controllers from malicious input), then finally handed to a controller. The controller loads the model, processes the request, and sends the result to the view system.

CodeIgniter helpers, libraries, extensions
Though it has a small footprint, CodeIgniter is extensible through a variety of mechanisms: helpers, libraries, class extensions, and hooks. A helper is a collection of functions that handle related tasks. CodeIgniter includes a sizable collection of helpers: for preloading input forms with data taken from arrays or objects, for JSON (JavaScript Object Notation) and the Mootools JavaScript library, for managing digital media, and more. By comparison, a library provides more extensive behavior than a helper. CodeIgniter has libraries for user login and authentication, session management, encryption, file uploading, and so on.

A class extension is -- as its name implies -- simply the PHP mechanism for extending the instance variables and methods of an existing class to provide specialized capabilities. Finally, CodeIgniter hooks let you alter the behavior of the framework itself, without having to hack into the code. You define a hook by specifying a hooking point. For example, the pre_system hooking point attaches the hook early in the process of system execution, while the post_system hooking point lets you inject behavior after the Web page has been rendered. You then associate class and method, as well as the file path to the class and method that you want invoked. When the application's execution hits the hooking point, CodeIgniter will dynamically load and execute your code.

Test Center Scorecard
CodeIgniter 1.7.38989


Very Good

CodeIgniter supports the MVC pattern loosely. You can, for example, employ only controller and view components if no back-end database (and, therefore, no model) is required. CodeIgniter uses the active record database pattern for database access, and the framework's database access methods are straightforward and easily mastered. For example, a simple get() method looks like this:

$query = $this->db->get('theTable');

This retrieves all the data from table theTable. You can modify this in a fashion mimicking an SQL WHERE clause where the second argument is an associative array that specifies the fields participating in the WHERE conditional:

$query = $this->db->get_where('mytable', array('id'=>$id, $limit, $offset);

CodeIgniter even provides methods that let you assemble more complex queries by chaining together comparison operations joined by AND and OR logical operators.

To continue reading, please begin the free registration process or sign in to your Insider account by entering your email address:
From CIO: 8 Free Online Courses to Grow Your Tech Skills
View Comments
You Might Like
Join the discussion
Be the first to comment on this article. Our Commenting Policies