All projects in this book make use of the MY_Controller
file; this is the same for all projects.
Create the MY_Controller.php
file at /path/to/codeigniter/application/core/
and add the following code to it:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class MY_Controller extends CI_Controller { function __construct() { parent::__construct(); $this->load->helper('form'); $this->load->helper('url'); $this->load->helper('security'); $this->load->helper('language'); // Load language file $this->lang->load('en_admin', 'english'); } }
As you can see, we load helpers that are common to all projects, such as the form
helper and the language
helper, among others. The language file is also loaded here.
All the controllers in the project extend from this MY_Controller
file rather than the default CI_Controller
file.