I was wondering if I could have more than one custom class in CodeIgniter 3? I currently have a custom class called AC_Controller which extends the CI_Controller.
I have put this in my config
/*
|--------------------------------------------------------------------------
| Autoload Custom Controllers
|--------------------------------------------------------------------------
|
*/
function __autoload($class) {
if (substr($class,0,3) !== 'AC_') {
if (file_exists($file = APPPATH . 'core/' . $class . '.php')) {
include $file;
}
}
}
This allows my AC_Controller to load but when I add another controller called AC_Repeat and reference it in a controller, I get this error Fatal error: Class 'AC_Repeat' not found.
So did I do something wrong or is only one custom class allowed?
core/? According to this answer, CI would load the AC_Controller class automatically anyway if you told it the prefix was AC_ in the config, but not the AC_Repeat because it's not a core class name it knows.