Fabulous PHP frameworks: CodeIgniter

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

1 2 Page 2
Page 2 of 2

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.

CodeIgniter's database connection information is stored in a multidimensional array. This allows you have multiple sets of database connection specifications -- say, one for development, another for testing, and so on. You can easily switch from one database to another by changing a single, global variable.

Keeping CodeIgniter simple
CodeIgniter installation is drag-and-drop simplicity. Download and unzip CodeIgniter, and you're provided with an application directory tree that you copy into your application server's Web home directory to begin your application's development. CodeIgniter has no command-line tools, nor does it use a templating language. Both omissions exemplify CodeIgniter's principle of simplicity.

In the case of the absent command-line tools, CodeIgniter's engineers wanted to minimize the number of entities supplied by an installation. CodeIgniter does not use a templating language for the simple reason that -- again, according to CodeIgniter's engineers -- PHP is already a templating language, so why create another? CodeIgniter documentation claims that, rather than try to learn PHP and a templating language, it's better to master PHP. In addition, code written in a template language must be processed and translated to PHP at runtime or converted to PHP in a separate build step -- there is a performance benefit to avoiding an independent template language.

CodeIgniter provides security on a number of levels. It restricts the characters that it will permit in an URL. Also, because it uses the "segmented model" for URLs it accepts, CodeIgniter simply disallows HTTP GET operations. In addition, CodeIgniter provides security libraries. You can, for example, call upon a CodeIgniter library to establish an XSS (cross-site scripting) filter that CodeIgniter will run on any incoming data.

CodeIgniter's documentation can be found on the website's wiki, and it includes a user guide and tutorials. There are two "official" video tutorials; the rest are tutorials linked to on external sites, and the number of those is remarkable. Not only are there "getting started" videos, which cover AJAX and managing uploads, you'll also find numerous entries written on topics such as database manipulation, using views, integrating email, and more. The user guide itself has information on installation and getting started, as well as topic overviews, class references, and a reference for the system's available helpers.

Though some of the documentation is under development, the quantity of information linked to on external sites more than makes up for the lack. CodeIgniter's installation is a breeze, and although it does not have all the bells and whistles of some of the other frameworks, it is an excellent framework to get a Web application started quickly.

Read the reviews of other PHP frameworks:

Also on InfoWorld:

This article, "Fabulous PHP frameworks: CodeIgniter," was originally published at InfoWorld.com. Stay up on the latest news in software development and PHP at InfoWorld.com. For the latest business technology news, follow InfoWorld.com on Twitter.

Copyright © 2011 IDG Communications, Inc.

1 2 Page 2
Page 2 of 2
How to choose a low-code development platform