What is Configuration in Codeigniter

When you start work with codeigniter then this also necessary part to configure your website like Base url, Database, Libraries, Helper etc.

Configure Base Url

Goto application/config/config.php and put base Url here.


$config['base_url'] = '';

Configure Database

Goto to application/config/database.php and put database details here.

$db['default'] = array(
'hostname' => 'localhost',
'username' => 'root',
'password' => '',
'database' => 'codeigniter3',

Configure Autoload

In Codeigniter there are lot of Libraries, Helpers etc. So You want to access Libraries, Helper etc. Then There are two way to load these first is by autoload and second is manual. Here we discuss autoload.

Goto to application/config/autoload.php

$autoload['libraries'] = array(‘database’,'email');
$autoload['model'] = array('user_model', 'admin_model');

How to Connect with Database

There are two way to connect database

1- By autoload
$autoload['libraries'] = array(‘database’);

2- By manual
Use this line your controller,


Note: Best is use in constructor