A Fully Baked PHP Framework. CodeIgniter is a proven, agile & open PHP web application framework with a small footprint.
How It Works
CodeIgniter uses the MVC or Model View Controller architectural pattern, if your not familiar with MVC it is a logical object orientated development approach. below we look at a simple example of how we use the MVC.
Controllers
A controller is simply a class file that is named in a way that can be associated with a URI. For example if i have a controller with the filename account.php the URI to reach that page would be something like http://your-domain.com/account/ so you no longer need to fiddle with the .htaccess file and mod_rewrite to enable SEO friendly URI’s. The controller is the top level file for each page that allows you to include database requests in the form of ‘Models’ and templates as ‘Views’. below is an example of a controller, This code would be saved in the file blog.php, it’s important to understand the naming convensions because the name of the file is always the name of the class with the first letter capitalised. Within the Blog class we have an index() function which is always loaded when the page is excecuted. For example if we had another function lets say ‘categories’ the code within that function would only be executed if we visited http://your-domain.com/blog/categories/ this is also the way you can pass url parameters into functions but we’ll leave that for another day. We’re loading our ‘View’ in at the bottom and passing the array $data into it. Within the view file which would be called blogview.php if we wanted to echo the heading we’d simply echo $heading the same with the title. With the to do list we would need to setup a for each loop to cycle through the results in that array.
class Blog extends Controller {
 
    function index()
    {
        $data['todo_list'] = array('Clean House','Run Errands');
        $data['title'] = 'My Real Title';
        $data['heading'] = 'My Real Heading';
 
        $this->load->view('blogview', $data);
    }
}
 
Models
As yet we’re not using a model, this is because our controller isn’t doing anything complex. If we wanted to connect to a database and get a set of results we would use a model which could look like the below. This is all the code we need to pull 10 results from the database which would be returned to the controller in an array. note that you would need to replace ‘tableName’ with your own database table name.
class Blogmodel extends Model {
 
    function Blogmodel()
    {
        // Call the Model constructor
        parent::Model();
    }
 
    function get_last_ten_entries()
    {
        $query = $this->db->get('tableName', 10);
        return $query->result();
    }
 
}
 
 
To include the model firstly you need to navigate to system/application/config/database.php and add your database connection details. then below you’ll see that i’ve modified the controller that we used earlier so it now connects to the database and gets our data. This will then be sent through to the ‘view’.
Views
Simply put a ‘View’ is our template, it’s where our data gets rendered and is made pretty, you can have as many views as you like and pass whatever data you like into them it’s probably a good idea to have a header, main content area and footer.
For Download Codeigniter : Click here