EDITING BOARD
RO
EN
×
▼ BROWSE ISSUES ▼
Issue 47

CodeIgniter PHP framework - a simple and useful tool

Cristian Tantar
Ads Server, PHP Developer @Gameloft



PROGRAMMING

Following the KISS principle (Keep It Simple and Stupid) we have to look for the easiest option to implement, whenever we need a quick start for a project. Symfony and Laravel are currently the most popular frameworks. They are both built to encompass the most recent PHP concepts and Object Oriented Programming (OOP). But the system and software requirements, which go beyond the average complex installation, and the amount of code necessary to render a simple "Under construction" page might discourage a possible start up, a testing project or even small and mid-size websites.

CodeIgniter, on the other hand, focuses on simplicity, both in matters of installation and development & maintenance. Developed over the past 10 years and now at v3.0.6, CodeIgniter can be used for any type of project, from a blog or presentation website to a portal, a REST server or an e-commerce shop.

Compared to other frameworks used at the moment, CodeIgniter is extremely easy to use. This makes it top 5, both for its popularity and memory usage or speed.

Here are some of the reasons CodeIgniter is worth a try:

The application flow is very clear and simple (https://codeigniter.com/user\\\_guide/overview/appflow.html):

Routing - The really simple routing configuration is made in application/config/routing.php. You can write the entire URL or use RegExp expressions.

The work methodology is classic : /controller/method/. The first URL segment is the controller that will be loaded and the second segment is the called method. But of course any other version can be used.

Security - CodeIgniter includes default classic security characteristics : url (URI) security, register_globals(\$_GET, \$_POST, \$_REQUEST, \$_COOKIES) security, XSS filtering, CSRF protection, Form Validation.

Application Controller - The controller extends the CI_Controller. (location: application/controllers/)

Views - The view is a page or an HTML fragment (e.g.: header, footer). It is not called directly by the URI, but through the controller, using the following syntax: \$this->load->view('name'); Location: application/views. No "Template Engine" is necessary, as it would only encumber both the development and the maintenance. Standard PHP code is more than enough.

Caching - The caching system is an important element in project development. CodeIgniter allows page(view) caching and also database results caching.

Models - Models are classes used for data (and database) manipulation. Location: application/models (obviously). The model extends a base model (CI_Model) and can be called from the Controller after being initialized, either from the configuration file config/autoload.php or by using the syntax : \$this->load->model('model_name');

The Database - CodeIgniter supports the most popular databases: cubrid, ibase, mssql, mysql (mysqli), oci8, odbc, pdo, postrgre, sqlite, sqlite3. The configuration is very simple in application/config/database.php. It is possible to use multiple databases simultaneously.

Libraries - For any type of project we also need built-in code. Application libraries are the place where our own libraries are located. These are classes loaded in the Controller, using the syntax: \$this->load->library('someclass').

Languages - Content translation is another important aspect of any project. Loading the translation files: \$this->lang->load('filename', 'language'), showing a translation line: \$this->lang->line('language_key').

Helpers - The "helper" files can be used for built-in functions, where you can declare all necessary functions. CodeIgniter comes with 30 built-in libraries necessary for almost any kind of project. Among these libraries, the following are included: Benchmark, Email, Caching, Encrypt, File Upload, Form Validation, Image Manipulation, etc.

As you can see, it is possible to load strictly what we need for a specific Route, with no extra classes or object. This is the reason CodeIgniter has a very low memory usage and is very fast.

Composer can also be used together with any library if an even faster development of the project is desired.

As mentioned above, one of the framework's strengths is the documentation. Here you can find all the information necessary for the project development, from A to Z: https://codeigniter.com/user_guide/index.html.

References:

  1. https://codeigniter.com

  2. https://github.com/bcit-ci/CodeIgniter

  3. https://sitepoint.com/best-php-framework-2015-sitepoint-survey-results/

  4. https://revillweb.com/tutorials/codeigniter-tutorial-learn-codeigniter-in-40-minutes/

  5. https://facebook.com/codeigniter/

VIDEO: ISSUE 109 LAUNCH EVENT

Sponsors

  • Accenture
  • BT Code Crafters
  • Accesa
  • Bosch
  • Betfair
  • MHP
  • BoatyardX
  • .msg systems
  • P3 group
  • Ing Hubs
  • Cognizant Softvision
  • Colors in projects

VIDEO: ISSUE 109 LAUNCH EVENT