Following are the step to upgrade your legacy CodeIgniter 2.x application into CodeIgniter 3.x application. CodeIgniter 3.x supports new versions of PHP and has more security and faster execution.

1- Update your CodeIgniter files

Go to system folder replace all files and directories in your system/ directory and replace your index.php file.
If any modifications were made to your index.php they will need to be made fresh in this new one.
if you have any custom developed files in system folder please make a copy of them first.

2- Move your Log class overrides or extensions

The Log Class is considered as a core class and is now located in the system/core/ directory. Therefore, in order for your Log class overrides or extensions to work, you need to move them to application/core/:

application/libraries/Log.php -> application/core/Log.php
application/libraries/Input.php -> application/core/Input.php

3- Update your classes file names

In Codeigniter 3.x all class filenames (controllers, model, drivers, libraries) must start with a capital letter. For examples:

Library

application/libraries/mylibrary.php -> application/libraries/Mylibrary.php

Controllers

application/controllers/welcome.php -> application/controllers/Welcome.php

Models

application/models/welcome_model.php -> application/models/Welcome_model.php

4- Replace config/mimes.php

mimes.php config file has been updated in 3.x to contain more user mime-types. Please replace mimes.php config file with new 3.x codeigniter mimes.php config file.

5- Update your Session library usage

The Session Library has been completely re-written in CodeIgniter 3 and now comes with a new features.

  • The table session table structure has changed a bit:
  • session_id field is renamed to id
  • user_agent field is dropped
  • user_data field is renamed to data and under MySQL is now of type BLOB
  • last_activity field is renamed to timestamp
  • Before Codeigniter 3.x unset_userdata function used to accept an associative array of ‘key’ => ‘value’ pairs for unsetting multiple keys.
  • Now Codeigniter 3.x only key as the elements of array no need to pass value.
    $this->session->unset_userdata(array('name' => 'abc', 'email' => '[email protected]')); -> $this->session->unset_userdata(array('name', 'email'));

6- Replace your error templates

In CodeIgniter 3.x the error templates are now considered as views and have been moved to the application/views/errors/html directory. Furthermore in Codeigniter 3.x, there is support for CLI error templates in plain-text format that unlike HTML. You can move your old files from application/errors to application/views/errors/html but you have to copy the new application/views/errors/cli directory from the CodeIgniter 3.x and past into application/views/errors/cli directory.

7- Update Config/database.php file

In Codeigniter 3.x renaming of Active Record to Query Builder inside your config/database.php.
you will need to rename the $active_record variable to $query_builder with true value.

// $active_record = TRUE;
$query_builder = TRUE;

8- Update your config/routes.php any wildcard

CodeIgniter has always provided the :any wildcard in routing. In Codeigniter 2.x the :any wildcard is represent with .+.
This is considered a bug as it also matches the / (forward slash) character which is the URI segment delimiter.
In CodeIgniter 3 the :any wildcard will now represent [^/]+, so that it will not match a forward slash.

9- Update usage of Database Forge’s drop_table() method

In Codeigniter 3.x the IF EXISTS condition is no longer added by default and has an optional second parameter [TRUE]
and is set to FALSE by default.
$this->dbforge->drop_table(‘table_name’); -> $this->dbforge->drop_table(‘table_name’, TRUE);

10- Many functions now return NULL instead of FALSE on missing items

Many methods and functions now return NULL instead of FALSE when the required items don’t exist.
uri->segment(), session->flashdata();

11- Remove previously deprecated functions

The SHA1 library

In Codeigniter 3.x previously deprecated SHA1 library has been removed now your code to use PHP’s native sha1() function to generate a SHA1 hash.

Security helper do_hash()

In 3.x, Codeigniter now uses PHP native hash() function instead of do_hash() function.

String helper trim_slashes()

In Codeigniter 3.x now uses trim() function instead of trim_slashes().

Form helper form_prep()

In Codeigniter 3.x now uses html_escape() function instead of form_perp() function.

Date helper standard_date()

Date Helper function standard_date() is being deprecated in Codeigniter 3.x due to the availability of native PHP constants. Which when combined with date() function provide the same functionality.

12- Upgrade your CodeIgniter 2 application now!

You can email to discuss with CodeIgniter expert to update your 2.x application to a newer 3.x and 4.x versions.

Related: 8 Steps to CodeIgniter performance optimization

Upgrading PHP CodeIgniter 2.x version project to 3.x

Following are the step to upgrade your legacy CodeIgniter 2.x application into CodeIgniter 3.x application. CodeIgniter 3.x supports new versions of PHP and has more security […]
Some Simple Hacks of Ecwid

3 Useful Ecwid Hacks

Introduction Ecwid is an eCommerce platform that helps to easily create online store and start selling your products instantly anywhere around the globe. Ecwid is a […]
Learn to develop Laravel RESTful API

Learn to develop Laravel RESTful API

Laravel RESTful API Development, Step By Step Previously we have discussed how to integrate Laravel APIs in Angular app. In this tutorial we will learn how to […]

How to integrate PHP Laravel 5.8 APIs in Angular 7

When we want to extend functionality in WordPress project, we cannot do changes in core files because, WordPress updates frequently (currently at verion 5) and all changes will be overwritten back to default files of new version. Hence, the need for plugins for adding extra functionality. These are our experiences and process we employ at The Right Software to develop a WordPress plugin.

How to integrate Stripe Connect in On-Demand apps in PHP

For a client, we were hired as WordPress developers. One of the problem was simple request. How to use WooCommerce to only allow next day delivery if before 1pm and day after tomorrow if ordered after 1pm.
How to develop a Wordpress plugin

How to develop a WordPress plugin

When we want to extend functionality in WordPress project, we cannot do changes in core files because, WordPress updates frequently (currently at verion 5) and all changes will be overwritten back to default files of new version. Hence, the need for plugins for adding extra functionality. These are our experiences and process we employ at The Right Software to develop a WordPress plugin.
4 Best WordPress caching plugins compared (2019)

4 Best WordPress caching plugins compared (2019)

Use iOS Multiple Targets with CocoaPods to develop two types of iOS apps using a single view application containing a UITableView. We're going to load different ULRs based on the project type and load the appropriate content.

How to enforce HTTPS in Laravel

Installing SSL (URLs that start with https://) on your PHP project and implementing that in your code can be achieved by updating .htaccess file of your […]
Integrate PHP with NightsBridge: Integration and Price API Tutorial

How to integrate PHP website with NightsBridge : Integration and Price API Tutorial

NightsBridge is a property listing and booking platform in South Africa. We discuss how to set up affiliate Agency website that can list NightsBridge properties, NightsBridge white label link and finally, how to update your property listings with NightsBridge price API. Source code and examples included.
set up woocommerce shipping tutorial

Tutorial: Set up WooCommerce Shipping

Shipping is an important part of any ecommerce business if it is dealing in physical products. We will show you how to configure and set up WooCommerce shipping feature to deliver your physical products. We dsicuss product types, shipping types, zones and flat rate.
Twitter Bootstrap vs AngularJS: Their comparison and usage

Twitter Bootstrap vs AngularJS: Their comparison and usage

Twitter Bootstrap and AngularJS can be used combined to make awesome web applications. AngularJS mainly deals with the logical part of the application while Bootstrap deals with the design. Your application will handle server tasks, HTTP, user interaction through AngularJS and after decision-making, AngularJS returns the control to the browser DOM in shape of code/HTML injection. Thats where Twitter Bootstrap is.
php framework comparison

PHP Framework Comparison: CodeIgniter vs Laravel vs Yii vs CakePHP

We provide a handy PHP Framework comparison for 2018. Our development team discusses CodeIgniter, Laravel, Yii and CakePHP to come up with a handy grading system to see which is the best PHP framework for your PHP web project development.