CodeIgniter Configuration

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

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

Database configuration:

CodeIgniter provides a configuration file in config folder with name database.php to connect with database.

Open the database.php file located in application/config/database.php directory

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

$db['default']['dsn'] = ''; 
$db['default']['hostname'] = 'localhost';
$db['default']['username'] = 'root'; // username
$db['default']['password'] = 'xxxx'; // password
$db['default']['database'] = 'database_name'; // database
$db['default']['dbdriver'] = 'mysqli'; 
$db['default']['dbprefix'] = ''; 
$db['default']['pconnect'] = FALSE; 
$db['default']['db_debug'] = (ENVIRONMENT !== 'production'); 
$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']['encrypt'] = FALSE; 
$db['default']['compress'] = FALSE; 
$db['default']['stricton'] = FALSE; 
$db['default']['failover'] = array(); 
$db['default']['save_queries'] = TRUE; 

Autoload Configuration:

  • This file specifies which systems should be loaded by default.
  • Frequently used systems should be autoload instead of called at the local level repeatedly.
  • Used to keep the framework as light-weight.

Libraries

$autoload option 'libraries' is a list of libraries that should be auto loaded.

$autoload['libraries'] = array('session', 'email', 'database');

In above code, we are auto loading session, email and database libraries.

Helper

$autoload option 'helper' is a list of helper files that should be auto loaded.

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

In above code, we are auto loading file and url helpers.

Config

$autoload option 'helper' is a list of config files that should be auto loaded.

$autoload['config'] = array('config1', 'config2');

In above code, we are auto loading config1 and config2 configuration file.

Language

$autoload option 'helper' is a list of language files that should be auto loaded.

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

Models

$autoload option 'helper' is a list of model files that should be auto loaded.

$autoload['model'] = array('model1', 'model2');

In above code, we are auto loading model1 and model2.