My preference for an MVC is CodeIgniter. It’s a nice light-weight MVC PHP framework with a great community and excellent documentation. This blog post is going to be a quick how-to regarding the setup of CodeIgniter from a fresh install.
Step 1. Get CodeIgniter 2.1
Go ahead and grab the CodeIgniter 2.1 framework from the CI website: http://codeigniter.com/downloads/
Once you have the framework unzip it into your web root. If you are running a LAMP server then your web root is likely /var/www. I use WAMPServer as a test instance on my Windows 7 machine. The web root for the default WAMP install is C:\wamp\www.
You don’t actually need all of the files in the zip folder, just the application folder, system folder, and index.php file.
Step 2. Remove the index.php from the URI with .htaccess and mod_rewrite
All traffic on your CodeIgniter site will go through the index.php file that you copied over into your web root. This leaves an ugly little artifact behind in your website’s URI. If left unchanged, your URI will be set up like this: {domain}/index.php/{segments}. I always like to remove this index.php from the URI. This isn’t really necessary, but if you want your CodeIgniter powered site to look professional, I would suggest doing this.
The first thing you’ll need to do in order to bypass the index.php segment of your URI is to make sure that the mod_rewrite module for Apache is enabled. I believe most LAMP installs have this set up by default. All of the LAMP servers that I have paid hosting on have had this module set up. If you would like to set this up in WAMP right click the WAMP icon in your system tray, hover over Apache from the resulting context menu, Apache Modules after that, and click the rewrite_module option to put a check mark beside it. WAMP will restart and mod_rewrite will be enabled.

Next create a file named .htaccess in your web root. Put the following code in this file and save it. You can read more about this file from the CI wiki page where the code was found: http://codeigniter.com/wiki/mod_rewrite.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
#Removes access to the system folder by users.
#Additionally this will allow you to create a System.php controller,
#previously this would not have been possible.
#'system' can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
#When your application folder isn't in the system folder
#This snippet prevents user access to the application folder
#Submitted by: Fabdrol
#Rename 'application' to your applications folder name.
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends the
#request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
# If we don't have mod_rewrite installed, all 404's
# can be sent to index.php, and everything works as normal.
# Submitted by: ElliotHaughin
ErrorDocument 404 /index.php
</IfModule>
Open your application/config/config.php file and change:
$config['index_page'] = 'index.php';
to
$config['index_page'] = '';
Step 3. Setup the config.php, database.php and routes.php Files
In the application/config/config.php file set $config['base_url'] to reflect your domain (e.g. www.someurl.com or localhost).
There are lots of other settings that you may want to set regarding sessions, encryption, xss filtering, logging, csrf, cookies, and more. I encourage you to read through this thoroughly and set up the values to best suit your site.
If you are going to connect to a database you will need to set up the application/config/database.php file. The array values are pretty self explanatory. Just read through the comment block at the head of the file and you will easily be able to determine what information is needed, where.
In the application/config/routes.php file you will see an array value that looks like this:
$route['default_controller'] = "welcome";
I hate using welcome.php as my default controller. Generally, I would suggest that you change this value to index. However, index.php won’t work in CodeIgniter. Because of the way CodeIgniter is built, if you do use index.php and you have an index( ) function (which is the default function for each controller) the index( ) function will get called twice. So, while you don’t have to change this value I personally prefer home to welcome because it makes more sense.
Viola! You’ve Done It!
That’s it. You have a working CodeIgniter framework. Test it a bit to make sure that everything is working as it should.
Of course you will likely want to do much more customization of your framework if you’re running more than a test site. These changes will become apparent as your site begins to flesh out and the scope of your project becomes clearer.
Good luck!
