Main Content

Teaching CodeIgniter - MVC and PHP

Archive - Originally posted on "The Horse's Mouth" - 2013-06-12 19:49:44 - Graham Ellis

CodeIgniter is becoming a very popular web Framework for PHP, and I can see why. Another private session today with a customer who wanted to go through the whole MVC thing - well experienced in web and PHP, and objects too... just needing to get into Frameworks to write code that's more re-usable and maintainable amongst other things.

Downloaded CodeIgniter, unzipped it into a directory within the document root, and added a few file... by the end of the day we had model, view, controller; sessions, forms with validation, and sticky fields. Shared headers and footers across a number of different pages. Routing of lots of URLs to the same controller script.

With ANY Framework, getting to the first application that uses all the major elements (as outlined above) is the biggest hurdle - from "hello world" to real application. With CodeIgniter, my demonstration was just 8 files and it could have been fewer! Here they are:

Router .htaccess
Controller controllers/passenger.php
Model models/places_model.php
View (header) views/transwilts_top.php
View (footer) views/transwilts_tail.php
View (most pages) views/mainpages.php
View (form) views/mailpage.php
Configuration (for session security) config/config.php

I'm happy to teach you PHP - we have a variety of courses from the basics of programming in PHP - Learning to Program in PHP - through PHP Programming to PHP Techniques, where we look at Frameworks, Service and other more advanced topics too.