CodeIgniter is a robust web application framework for PHP. It is based on the Model-View-Controller approach for an ideal separation of logic from presentation.
Its aim is to allow people to write their applications much quicker than normal by providing a set of libraries and helpers for the most common tasks.
Navigate to your server’s directory root folder. Download the latest version of CodeIgniter:
mv /var/www/CodeIgniter-3.0.1 /var/www/codeigniter
You can check by opening it in your browser as :
There, you will see the CodeIgniter welcome message.
Configuring MySql Dtabase For Codeigniter
Now you need to set up database and provide the information for CodeIgniter to be able to communicate with it. Edit the following file :
Edit database.php to include your database information. Save the file and exit .
$db[‘default’][‘hostname’] = ‘localhost’;
$db[‘default’][‘username’] = ‘your_username’;
$db[‘default’][‘password’] = ‘your_password’;
$db[‘default’][‘database’] = ‘your_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;
Next, open the config.php file and set your base url. Save the file and exit.
$config[‘base_url’] = ‘http://www.example.com’;
The next factor you’ll most likely want to change is to remove the index.php segment you need to put in the URL right before your Controller name. Open the config file and change the code :
$config[‘index_page’] = ‘index.php’;
$config[‘index_page’] = ”;
Save and exit. However that is not sufficient. It simply signifies that you’re going to get a bunch of “Page not found” errors if you simply omit it from the URL. Additionally, you will have to create an .htaccess file to deal with some redirects .
Create the .htaccess file within the CodeIgniter root folder (next to the index.php file):
And paste following code:
RewriteCond % !-f
RewriteCond % !-d
RewriteRule .* index.php?/$0 [PT,L]
Be certain that your .htaccess file is enabled by setting AllowOverride to All in the virtual hosts file:
Options Indexes FollowSymLinks MultiViews
enable from all
Save file and exit. Now its ready to start out creating your PHP application using CodeIgniter.