Get in Touch

Call Us on 1300 727 952
Find us

First Floor, 159 Victoria Pde
Collingwood, VIC 3066
(Google Map)

1300 727 952 
+61 3 9910 4099


Get in touch


Upgrading a CodeIgniter 1.x site to CodeIgniter 2.0

Hallelujah! CodeIgniter has finally released version 2.0.0 after a very long and patient wait, as a stable, production ready framework.

salsa 8 February 2011

Hallelujah! CodeIgniter has finally released version 2.0.0 after a very long and patient wait, as a stable, production ready framework. It was deemed more stable than the 1.7.2 version for quite a while before it was officially released, as all bugs that were fixed in the old version were applied to the dev version at the same time, while making further improvements. So the usual deal of waiting a few months while a new major release goes through it's teething stage thankfully doesn't apply here, it's ready to roll right now.

What do you need to know?

There are a few new items in 2.0 which you can read in more detail about on their website, however the main points to note if you are planning an upgrade are:

  • PHP4 support is gone, the lowest version of PHP supported is 5.1
  • The validation class (which was deprecated) has been completely removed, the form_validation class has taken over
  • Scaffolding has been removed (this was also deprecated)
  • Plugins have been removed, Helpers are to be used instead

What do you need to do?

As always, take a full backup before you make any changes so you can rollback.

Download the latest version of CodeIgniter Reactor and extract it somewhere on your computer.

Hopefully you've only made changes to the files in the system/application folder. If you've made changes to anything else in the system folder, you'll need to go back and move those changes to where they should be in the system/application folder before you can move forward.

The system/application folder in 2.0 has been moved to the top level, so first thing you need to do is move your system/application folder to sit in the root alongside the system folder.

Now delete the system folder.


You've now removed the CodeIgniter base, simply swap in the system folder that you downloaded from the CodeIgniter site, add the following additional files from the download into your site, and we're ready to move on to a few convention changes.

  • index.php
  • application/config/foreign_chars.php
  • application/ config/profiler.php

Convention changes

In each of your controllers and models, (unless you've created your own base controller to extend, in which case you only need to update your base controller) you are probably doing something like

class user_model extends Model

You'll need to go through and change this to

class user_model extends CI_Model

The same goes for controllers, whereby instead of extending Controller, you need to now extend CI_Controller

Change your plugins to helpers

If you've written or downloaded any plugins to use on your site, you're going to have to convert them into helpers. It's a pretty simple change, just move the files in the plugins folder to the helpers folder, rename them from xxx_pi.php to xxx_helper.php. Then update your config.php file to make sure you are autoloading the same files as before but now as helpers. That's it!

Move over to Form Validation

You can in theory get the old validation.php file from the 1.7.2 version of CodeIgniter and place it in your application/libraries folder and be done with it. However, if you can spare the time it's more beneficial to use the new Form Validation class as you'll be able to take advantage of the much neater code and also keep on top of any updates and improvements made over time. When working with user data, keeping on top of security releases can be a pretty important thing. The small amount of effort is worth it.

That's it.

You've just upgraded to a version 2.0 base. Now you need to give everything on your site a thorough test to make sure that everything is in working order.

There are a few more left field items, but for 90% of sites out there using CodeIgniter 1.7.2 this will cover you for making the upgrade pretty painlessly.

If you do get stuck, remember there's a very active userbase on the CodeIgniter forums only too happy to help out.

Subscribe to the Salsa Newsletter

Subscribe to the Salsa newsletter

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now