Most code I create and that I have seen built on CodeIgniter use custom base controllers but do not always start their names with “MY.”
I like to use things such as:
Public_Controller.php and Admin_Controller.php
In CodeIgniter 2.0 they move custom base classes (controllers) from the “applications/libraries” folder to the “applications/core” folder.
If you followed Phil Sturgeon’s guide on using custom base classes then you know you need to add an auto-load to the config.php file. Hover the code he shares still tries to load the files from the “libraries” folder. I have changed the code to try and load them from the “core” folder and I wanted to share it with you.
/*
| -------------------------------------------------------------------
| Native Auto-load
| -------------------------------------------------------------------
|
| Nothing to do with config/autoload.php, this allows PHP autoload to work
| for base controllers and some third-party libraries.
|
*/
function __autoload($class)
{
if(strpos($class, 'CI_') !== 0)
{
@include_once( APPPATH . 'core/'. $class . EXT );
}
}Simply stick that at the bottom of your application/config.php file and your good to go for CI2.0
Note: if you already have it defined be sure to remove the current one or you will have an error.
Cheers,
Randy Cram