title: CodeIgniter 2: How to extend CI_Controller multiple times?
body: <p>I have successfully extended the CI_Controller class by creating a MY_Controller.php which I have placed in the application/core directory.</p>
  
  <p><strong>core/My_Controller.php looks something like this:</strong></p>
  
  <pre><code>class MY_Controller extends CI_Controller {
  
      function __construct()
      {
          parent::__construct();
      }
  }
  </code></pre>
  
  <p><strong>Then when I create normal controllers they look something like this:</strong></p>
  
  <pre><code>class Home extends MY_Controller {
  
      function __construct()
      {
          parent::__construct();
      }
  
      function index()
      {
          $this-&gt;load-&gt;view('home');
      }
  }
  </code></pre>
  
  <p>I'm creating a admin back end and I want to have a different base class for controllers to extend instead of My_Controller. This is so I can have common methods for the admin controllers (i.e. authentication_check etc.)</p>
  
  <p>What I can't work out is how I create another controller that extends CI_Controller.</p>
  
  <p>The goal is for admin controllers to extend a different base class than the front-end controllers.</p>
  
  <p><strong>The admin base controller would look like this:</strong></p>
  
  <pre><code>class MY_Admin_Controller extends CI_Controller {
  
      function __construct()
      {
          parent::__construct();
      }
  }
  </code></pre>
  
  <p><strong>An normal controller for admin pages:</strong></p>
  
  <pre><code>class Admin_home extends MY_Admin_Controller {
  
      function __construct()
      {
          parent::__construct();
      }
  
      function index()
      {
          $this-&gt;load-&gt;view('admin_home');
      }
  }
  </code></pre>
  
  <p>The problem is that to extend the CI_Controller class you must name your controller file PREFIX_Controller.php and place it in the core/ directory. But I want two controller classes and they can't have the same filename.</p>