Is there any super controller or global controller in Codeigniter Is there any super controller or global controller in Codeigniter codeigniter codeigniter

Is there any super controller or global controller in Codeigniter


Shared controller functions should usually be in an extended controller class:

<?php/** *  File: /application/core/MY_Controller.php */class MY_Controller extends CI_Controller {    /**     * Prefix with an underscore if you don't want it     * publicly available through URI-routing     */    public function _some_shared_method()    {        // some common operation here    }}

Then, make sure any controller that needs to use this function extends MY_Controller.


You would be breaking MVC by calling a controller from another controller. Consider either using a helper, or library for the function you are trying to call.

When controllers call other controllers you're operating in an HMVC framework. See Modular Extensions

If you're looking for information on controller inheritance, I recommend reading Phil Sturgeon's post on Keeping It Dry