You are currently viewing How to install or setup CodeIgniter In Xampp Server

How to install or setup CodeIgniter In Xampp Server

CodeIgniter is a very popular and powerful Model View Controller(MVC) framework which is used to develop full-featured web applications. It is a free and Open source PHP framework

CodeIgniter was created by EllisLab, and is now a project of the British Columbia Institute of Technology. The latest version of CodeIgniter framework is 3.1.11 which requires PHP 5.6+. CodeIgniter 4 is the upcoming version of the framework.

Here, we will see step by step process to install Codeigniter 3.1.11 using XAMPP local server on windows 10. To install, codeigniter follow below steps,

Step 1) Download the latest CodeIgniter

First, download the latest stable version of codeigniter from the official codeigniter website. You can download by click on this link https://codeigniter.com/en/download.

Codeignite download

Step 2) Unzip the download file

Unzip the downloaded zip file in your htdocs folder. Here in my case it is E:\xampp\htdocs. I have extracted file here and changed folder name to opencart.

Step 3) Set the baseurl

Set the baseurl “http://localhost” for your codeigniter project by opening application/config/config.php file with a text editor.

$config['base_url'] = 'http://localhost';

Step 4) Change database details

Next step is to change the database details, If you need to change the database details open the application/config/database.php file with a text editor and set your database settings as per database you have created. Here i have created database name “codeigniter” in phpmyadmin and configured database.php file below.

$db['default'] = array(
	'dsn'	=> '',
	'hostname' => 'localhost',
	'username' => 'root',
	'password' => '',
	'database' => 'codeigniter',
	'dbdriver' => 'mysqli',
	'dbprefix' => '',
	'pconnect' => FALSE,
	'db_debug' => (ENVIRONMENT !== 'production'),
	'cache_on' => FALSE,
	'cachedir' => '',
	'char_set' => 'utf8',
	'dbcollat' => 'utf8_general_ci',
	'swap_pre' => '',
	'encrypt' => FALSE,
	'compress' => FALSE,
	'stricton' => FALSE,
	'failover' => array(),
	'save_queries' => TRUE
);

Step 5) Check codeigniter

To check CodeIgniter install successfully or not open the given link in your browser. You can open your project by http://localhost/Folder name. Here Folder name is your project name and in our case it is codeigniter, so we will open http://localhost/codeigniter/.

Create first program to print “Hello world”

In this example we will print Hello world using CodeIgniter framework PHP. We will create two file for hello world example.

  1. Helloworld.php (codeIgniter\application\controllers\ Helloworld.php )
  2. hello_world.php (codeIgniter\application\views\hello_world.php)
  1. Helloworld.php
<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Helloworld extends CI_Controller {

	public function index()
	{
		$this->load->view('hello_world');
	}
}

2. hello_world.php

<?php
defined('BASEPATH') OR exit('No direct script access allowed');
?>
<!DOCTYPE html>
<html>
<head>
<title>Hello World !</title>
</head>
</body>

<h1>Hello World !</h1>

</body>
</html>

Now run the program on your browser with the below URL and you find below output.

http://localhost/codeigniter/index.php/helloworld

Leave a Reply