How to install CodeIgniter – PHP framework
CodeIgniter is an open-source Web Application framework built in PHP designed to make your life as a programmer easier, while allowing you a good speed for development, and also good performance when the site is up and running.
- Easy to install and configure
- Clean and elegant MVC implementation
- Uses Active Record pattern for database access
- Overall small footprint and good performance
Requirements
CodeIgniter framework.
Any Apache/PHP/MySQL (Like: LAMP, WAMP, XAMPP). You can install the applications independently, or install one of those packages that have all of them bundled together.
Installing CodeIgniter
Step 1 : Downloading CodeIgniter Framework:
Download current version of CodeIgniter framework.
Step 2 : Installing CodeIgniter:
To install CodeIgniter, you only need to Unzip the package to the htdocs {OR} www directory of your Web Server.
Step 3 : Configuring CodeIgniter:
Rename the folder for convenience. For example: CodeIgniter
The next step is to Open the application/config/config.php file with text editor and set base URL.
Syntax:
//you can set base URL $config['base_url'] = "http://localhost/codeigniter/";
Step 4 : Testing CodeIgniter
Then check CodeIgniter application running properly
http://localhost/codeigniter
Step 5 : Database configuration :
Open the application/config/database.php file with a text editor and configure database
$db['default'] = array( 'dsn' => '', 'hostname' => 'localhost', 'username' => 'root', // Your username if required. 'password' => '', // Your password if any. 'database' => 'demo_DB', // Your 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 );
Step 5 :CodeIgniter htaccess and URL rewrite
1- Make below changes in application/config/config.php file
$config['base_url'] = 'http://'.$_SERVER['SERVER_NAME'].'/Your Ci folder_name'; $config['index_page'] = ''; $config['uri_protocol'] = 'AUTO';
2- Make .htaccess file in your root directory using below code
DirectoryIndex index.php RewriteEngine on RewriteCond $1 !^(index\.php|(.*)\.swf|forums|images|css|downloads|jquery|js|robots\.txt|favicon\.ico) RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ ./index.php?$1 [L,QSA]
3- Enable the rewrite engine (if not already enabled)