Extending your controllers

Inheritance is a wonderful thing; allowing you to define conceptual layers, or levels within an application, that is, allowing child classes to share traits and attributes of parent classes allows applications to model real-world examples more accurately and intuitively than standard procedural programming.

In CodeIgniter, the default design structure for your application is that the controller you create extends the main CodeIgniter controller. For example, in the following code, we have a Signin controller, which extends the main CodeIgniter controller, CI_Controller:

class Signin extends CI_Controller {
}

Your Signin controller will inherit the properties of the CI_Controller. However, CodeIgniter also allows you to ...

Get CodeIgniter 2 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.