Internationalization and Partial Rendering in the CodeIgniter Framework

September 6, 2010 No comments yet

As experienced Web developers, it won’t shock you to find literally thousands of comparisons between CodeIgniter and the other popular frameworks you may be considering for your site. Each framework has its good and, ummm… less good points, but

Building a Todo List using Code Igniter

April 18, 2009 No comments yet

A Query7 reader requested this tutorial to be written. It’s aimed to be a general guide to build ‘something’ using Code Igniter. It uses Models, Views, Controllers, Helpers and Libraries and will give you a good idea how Code Igniter works as a whole. I will be posting more advanced Code Igniter tutorials in the future.

Setup

Install and do some basic configuration (URL, database settings) of Code Igniter. If you don’t know how to do this, read here. Autoload the database library and url helper as we will be using them.

The user will be able to post new items and delete current items and the app itself will be made up of:

  • One Controller – todo.php
  • One Model – todo_model.php
  • One View – todo_index.php

PHP4 Compatibility

Because Code Igniter supports both PHP4 and PHP5, you are forced to use PHP4 style OOP. Your constructor must be the same name as the class, and it needs to contain parent::Controller(); or parent::Model();
The naming conventions for controllers and models are very strict. The name of both class and constructor must be the same as the file name, but capitalized. In our case of our controller,…

Getting started with Code Igniter

March 29, 2009 5 comments

What is Code Igniter?

Code Igniter is a PHP web framework which assists in creating complex websites. Unlike other web frameworks, Code Igniter doesn’t force you to use all of it’s components. You select and load them as you require. The only feature you have to use is the URL structuring (/controller/method/) which is very helpful anyway.

Code Igniter follows the Model, View, Controller (MVC) principle. All of your database queries are stored in models, HTML/XML output in Views and the logic code in Controllers. You aren’t forced to do this, however it does keep your code organized and reusable.

Helpers and Libraries

Like most frameworks, Code Igniter comes with many classes that help assist development. They are split into Libraries (AKA Classes) and Helpers. Libraries contain code that you could use on every page of your application – Database ORM, Image Manipulation, Pagination and Benchmarking. Helpers are things like Relative URLs, Forms and Email.

Using helpers and libraries is very easy. If you want it included throughout the site see below (autoloads). If you want it included for every method in a Controller, then you can add it to that Controller’s constructor. If you just want it included in…