CodeIgniter is an MVC framework. It is an Open Source Framework. It has a very rich set of functionality, which will increase the speed of website development work.
It is very easy to download and configure CodeIgniter. Just follow the steps given below :-
Step 1) Go to the CodeIgniter Official Website (Click Here). And Click on download button.
Step 2) Unzip the folder and upload to your server.
Step 3) Open the contents of CodeIgniter folder, you should be able to see the following files-
Step 4) After uploading folder on server. Visit the URL of your server, e.g., www.your-domain.com. you will see the following screen −
CodeIgniter Config Files
After setting up the site, let’s look at the configuration directory.
The application/config folder contains a group of files that set basic configuration of your site.
- autoload.php – set the drivers, helpers, packages, libraries, etc that should be auto loaded when the application starts
- config.php – contains common settings such as base url, language, query strings, etc.
- constants.php – define application constants
- database.php – contains database connection parameters
- hooks.php – allows you to define your own hooks
- routes.php – contains the application routes
Configuring Base URL
let’s make some most common settings in CodeIgniter
Change Base URL:
$config['base_url'] = '';
It is URL to your CodeIgniter root. If its blank then CodeIgniter will set it automatically.
$config['base_url'] = 'http://your-domain.com';
In this file we set the following variables – hostname, username, password, database, dbdriver (MySQL, MySQLi, Postgre SQL, ODBC, and MS SQL).
$db['default'] = array( 'dsn' => '', 'hostname' => 'localhost', 'username' => 'user', 'password' => 'pass', 'database' => 'database_name', '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 );
This file specifies, by default, which systems should be loaded. In order to keep the framework as light-weight as possible. Following are the things you can load automatically −
$autoload['libraries'] = array('database', 'email', 'session'); $autoload['drivers'] = array('cache'); $autoload['helper'] = array('url', 'file');