Php – Extending the Template Controller in Kohana

base-classextendingkohanaPHP

I'm having a bit of confusion in attempting to retroactively create a new base controller for my project. If I'm not mistaken, all I need to do is create a file in application/libraries called MY_baseController.php containing the following:

class baseController extends Template_Controller
{
  public function __construct()
  {
    parent::__construct();
  }
}

And then rewrite my other controllers to extend baseController instead of Template_Controller:

class Frontpage_Controller extends Template_Controller

to

class Frontpage_Controller extends baseController

Yet when I do this, accessing the Frontpage_Controller alerts me that:

Class 'baseController' not found…

What am I missing here?

Best Answer

After some fiddling, I think the following is my solution...

Move MY_baseController.php from application/libraries and into application/controllers. Rename it to base.php and change the following line:

class baseController extends Template_Controller

into

class Base_Controller extends Template_Controller

Now within your Frontpage Controller, extend Base_Controller instead of baseController.

Related Topic