Create static application with codeigniter and bootstrap 3

Hello World, This is second tutorial of codeigniter tutorial series “Learn Codeigniter from scratch” series.In this previous tutorial we have learnt that how we can setup codeigniter on local machine. In this tutorial we will create static application with codeigniter and bootstrap 3. I have divided this  tutorial in following parts:

  • Bootstrap Introduction
  • Create static application (with controller and view)

Bootstrap Introduction

According to their official documentation:

Build responsive, mobile-first projects on the web with the world’s most popular front-end component library.

Bootstrap is an open source toolkit for developing with HTML, CSS, and JS. Quickly prototype your ideas or build your entire app with our Sass variables and mixins, responsive grid system, extensive prebuilt components, and powerful plugins built on jQuery.

Create Static  application with codeigniter and bootstrap 3

In this series of tutorial we will work on todo list  application.

  • Create todo folder in application/views folder.
  • In this folder create todo.php file with following code.
<!DOCTYPE html>
	<title><?php echo $page_title; ?></title>
	<link rel="stylesheet" type="text/css" href="<?php echo base_url('public/bootstrap.min.css') ?>" />
	<div class="container">
		<h1 class="page-header">To-Do List <span class="badge">123</span></h1>
		<table class="table table-striped table-bordered">
			foreach($content as $task){
					<td><?php echo $task['task_title']; ?></td>
					<td><?php echo $task['task_status']; ?></td>
						<a href="#" class="btn btn-xs btn-primary">Edit</a>
						<a href="#" class="btn btn-xs btn-danger">Delete</a>
  • Now Create Todo.php in application/controllers folder.
  • Add the following code in this file.
defined('BASEPATH') OR exit('No direct script access allowed');

class Todo extends CI_Controller {
	function __construct(){
	// todo list
	function index(){
		$data['page_title']="To-Do List";
				'task_title'=>'Task 1',
				'task_title'=>'Task 2',
				'task_title'=>'Task 3',
				'task_title'=>'Task 4',
				'task_title'=>'Task 5',
				'task_title'=>'Task 6',

Currently, I have added the static code. But in the next tutorial we will fetch data from database.

  • Now we have settled up our controller and attached the view in it.
  • Lets check our static app in browser. Open the following link in the browser.


I know you are thinking why we put index.php in path. but Don’t worry it added by codeigniter default. In the next tutorial we will remove this from our path.

  • When you open the above path in your browser, you will see the following screen.



Congratulation, You have created static application with codeigniter and Bootstrap 3.

In the next tutorial of this series, we will Connect with database and fetch data from database with codeigniter. I hope you are enjoying this tutorial. Please share you experience via comment.

Leave a Reply

Your email address will not be published. Required fields are marked *