In Codeigniter 2.1.2 I want to create base controller and then extends from this controller. It does not work and I have no idea why and I'm pretty desperate now.
In \application\core\MY_Base_Controller.php I have this:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class MY_Base_Controller extends CI_Controller
{
function __construct()
{
parent::__construct();
...
In \application\controllers\Home.php I have this:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Home extends MY_Base_Controller {
And the error message is
Fatal error: Class 'MY_Base_Controller' not found in ...\application\controllers\Home.php on line 3
I have no idea what to do, I read all over the internet that I have to put base controller to core folder what I did, that I have to name base controller with prefix MY_, I did. But it is still no working. And in my config.php is this line as well
$config['subclass_prefix'] = 'MY_';
Im running this on localhost using xampp
Thank you for your help
EDIT
Could someone please downlod following link try it, and tell me whats wrong. I have just downloaded codeigniter tried to create base controller and extend welcome controller. Not working. In following rar there are just modified files. Thank you http://goo.gl/sKHkDl
EDIT 2
I'm able to get this working by renaming MY_Base_Controller to MY_Controller. Does this mean, I'm able to create only one extended class for a controller ? eg. I can not have
Just and only MY_Controller ?
I had the same problem, but if I created all controllers in the MY_Controller.php file all worked well.
<?php
class MY_Controller extends CI_Controller
{
function __construct()
{
parent::__construct();
// do some stuff
}
}
class MY_Auth_Controller extends MY_Controller
{
function __construct()
{
parent::__construct();
// check if logged_in
}
}