Codeigniter MVC Framework PHP

Installation and Configuration – CodeIgniter

CodeIgniter is a simple web application development framework for PHP.

We can separate logic from presentation by using a Model-View-Controller (MVC).

We are going to explai, how to install and configure the CodeIgniter framework. Below mentioned are the step by step process and installation instructions that you can follow to get CodeIgniter installed on your local computer.

 

Step 1 : Downloading CodeIgniter Framework

Go to http://www.codeigniter.com and download current version of CodeIgniter framework.

 

Step 2 : Installing and Exploring CodeIgniter

After download codeigniter we receive zip format file. So, we need to unzip, and rename to codeigniter.

Now copy it to your PHP and MySQL enabled server. In this tutorial we are using XAMPP. Copy it on C:\xampp\htdocs\

 

Step 3 : Configuring CodeIgniter

For running CodeIgniter application we need to setup the right base URL of the app. To do this, open up C:\xampp\htdocs\CodeIgniter\application\config\config.php and edit the base_url array item to point to your server and CodeIgniter folder.

Syntax:

//you can find this at line number 17

$config[‘base_url’] = “http://localhost/CodeIgniter/”;

 

Step 4 : Testing CodeIgniter

Here we do quick test to see CodeIgniter application running properly or not. Go to

http://localhost/codeigniter/

and you should see the following. Means its working proper

Step 5 : Database configuration

To connect with database CodeIgniter provides a configuration file in config folder with name database.php. Below is the mentioned path:-

C:\xampp\htdocs\CodeIgniter\application\config\database.php

To setup connectivity with your database you need to do the changes as mentioned in below code:

$db[‘default’][‘hostname’] = “localhost”;

$db[‘default’][‘username’] = “root”; // Your username if required.

$db[‘default’][‘password’] = “”; // Your password if any.

$db[‘default’][‘database’] = “database_name”; // Your database name.

$db[‘default’][‘dbdriver’] = “mysql”;

$db[‘default’][‘dbprefix’] = “”;

$db[‘default’][‘pconnect’] = TRUE;

$db[‘default’][‘db_debug’] = FALSE;

$db[‘default’][‘cache_on’] = FALSE;

$db[‘default’][‘cachedir’] = “”;

$db[‘default’][‘char_set’] = “utf8”;

$db[‘default’][‘dbcollat’] = “utf8_general_ci”;

$db[‘default’][‘swap_pre’] = “”;

$db[‘default’][‘autoinit’] = TRUE;

$db[‘default’][‘stricton’] = FALSE;

 

Leave a Reply

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