Basic Configuration of codeigniter,Basic setup of codeigniter

Download Codeigniter

first your are require to download latest version of Codeigniter click here Download

Configure Routes

Now go to application->config->routes.php and change these code

$route['default_controller'] = "welcome";

to

$route['default_controller'] = "UsersController";

Configure Database

Now go to application->config->database.php and cofigure database info and create database here codci in phpmyadmin

old
$active_group = 'default';
$active_record = TRUE;
$db['default']['hostname'] = 'localhost';
$db['default']['username'] = '';
$db['default']['password'] = '';
$db['default']['database'] = '';
$db['default']['dbdriver'] = 'mysql';
$db['default']['dbprefix'] = '';
$db['default']['pconnect'] = TRUE;
$db['default']['db_debug'] = TRUE;
$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;

New

$active_group = 'default';
$active_record = TRUE;
$db['default']['hostname'] = 'localhost';
$db['default']['username'] = 'root';
$db['default']['password'] = '';
$db['default']['database'] = 'codci';
$db['default']['dbdriver'] = 'mysql';
$db['default']['dbprefix'] = '';
$db['default']['pconnect'] = TRUE;
$db['default']['db_debug'] = TRUE;
$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;

Load basic libaries and helper

Now go to application->config->autoload.php and cofigure these info

old
/*
| -------------------------------------------------------------------
|  Auto-load Helper Files
| -------------------------------------------------------------------
| Prototype:
|
|	$autoload['helper'] = array('url', 'file');
*/

$autoload['helper'] = array();


/*
| -------------------------------------------------------------------
|  Auto-load Config files
| -------------------------------------------------------------------
| Prototype:
|
|	$autoload['config'] = array('config1', 'config2');
|
| NOTE: This item is intended for use ONLY if you have created custom
| config files.  Otherwise, leave it blank.
|
*/

$autoload['config'] = array();

New
$autoload['libraries'] = array('session');

$autoload['helper'] = array('form','login','url');

Here is login helper is a custom helper to check user loged in or not

So Now create login helper

Go to application->helpers->create login_helper.php and insert the following code

function is_logged_in() {
    $CI =& get_instance();
    $user = $CI->session->userdata('user_data');
    if(isset($user) && !empty($user['email'])){
	        return true;
    }else{
        return FALSE;
    }
}

Set Encrypeion key

Now go to application->config->config.php and cofigure these info

old
$config['encryption_key'] = '';

New
$config['encryption_key'] = 'abcd123456';

Controller

Now go to application->controllers->UsersController.php and insert the following code.

 if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class UsersController extends CI_Controller {

 function __construct()
  	{
		parent::__construct();
		
	}
public function index()
	{
	echo "Welcome To codeigniter";
	}

}

Next To Create Login And Registration

Share Button

About admin

Leave a Reply

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

*

Author: pramod kumar kumawat Mob: 9269727062
Free WordPress Themes - Download High-quality Templates