How to install and setup codeigniter framework

CodeIgniter is a powerful open-source PHP framework with a very small footprint, created by Rick Ellis in 2006.

I will present you a step-by-step instruction how to set up development environment from a codeigniter framework.In this tutorial I am using CodeIgniter 3.1.9.

1.) Download Codeigniter:

Download Codeigniter framework.

2.) Unzip the File:

Now Unzip the folder inside C:\xampp\htdocs. You can rename folder name like myapp .

3.) Initial testing:

Everything is ready so finally let’s launch the Codeigniter app.Now let’s move on to browser and type in URL http:\\localhost\myapp.You will get interface as showing in below.

4.) Database Configuration:

Let’s now setup the database located in myapp/application/config/database.php. Change the username,password and database name.

5.) Mysql database table:

Next,Create database table.In my case database name is myapp and the table name is tbl_user. You can create table by running below script.

CREATE TABLE `tbl_user` (
`id` int(11) NOT NULL,
`name` varchar(255) NOT NULL,
`mobile` varchar(255) NOT NULL,
`address` varchar(255) NOT NULL
ALTER TABLE `tbl_user`
ALTER TABLE `tbl_user`

6.) Creating View:

Next, create a view file in your myapp/application/views directory called registerview.php with this code.


font-family: Verdana;
font-size: 18pt;
font-style: normal;
font-weight: bold;
text-align: center;

font-family: Verdana;
font-size: 12pt;
font-style: normal;
font-weight: bold;
border-collapse: collapse;

<form name="registerview" action="<?php echo base_url(); ?>register" method="post">
<table align="center" cellpadding = "5">
<td><input type="text" name="name" maxlength="50"/></td>
<td><input type="text" name="mobile" maxlength="10"/></td>
<td><input type="text" name="address" maxlength="100"/></td>
<td colspan="5" align="center">
<input type="submit" value="Register"/></td>

7.) Creating Controller:

Next, create a controller in your myapp/application/controller directory called RegisterController.php with this code.Make sure first letter of controller’s name in Uppercase as like i mention below.


defined('BASEPATH') OR exit('No direct script access allowed');
class RegisterController extends CI_Controller {
public function index(){
public function register(){
$data = array(

8.) Creating Model:

Next, create a model in your myapp/application/model directory called RegisterModel.php with this code. Make sure first letter of model’s name in Uppercase as like i mention below.


class RegisterModel extends CI_Model {
private $table_name = 'tbl_user';
public function __construct() {
public function save($data){
$return = $this->db->insert($this->table_name, $data);
return $this->db->insert_id();

9.) Next, load the library and helper in autoload.php file located in myapp/application/config/autoload.php. 

$autoload['libraries'] = array('database');
$autoload['helper'] = array('url','html','file');

10.) Route Configuration:

Change the default controller in routes.php file located in myapp/application/config/routes.php. 

$route['default_controller'] = 'registercontroller';
$route['register'] = 'registercontroller/register';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;

Now,move on to browser and type in URL http:\\localhost\myapp.You will get interface as showing in below.

Thank you for reading this post. we hope you like this Post, Please feel free to comment below, your suggestion and problems if you face – let us know. We’d love to help!

I am Hitesh from Jamshedpur (India). I have been working as a Web Application Developer from last 4+ years. I love diverse and attention catching web presence for a variety of users. Also I love to learn new things in Web Development.

Tags: , , , , , ,