Skip to content

Instantly share code, notes, and snippets.

@morningtoast
Created June 2, 2015 14:11
Show Gist options
  • Select an option

  • Save morningtoast/afe92a4c276e95ccfeb4 to your computer and use it in GitHub Desktop.

Select an option

Save morningtoast/afe92a4c276e95ccfeb4 to your computer and use it in GitHub Desktop.
CodeIgniter autoload classes
/*
|--------------------------------------------------------------------------
| Autoload Custom Controllers
|--------------------------------------------------------------------------
| http://stackoverflow.com/questions/21351808/codeigniter-extending-controller-controller-not-found
|
| Add this to the bottom of /config/config.php
|
| As long as your library is prefixed with "MY_" and lives in the /core/ folder, this will
| autoload that library when you extend without having to otherwise include it.
|
|
*/
function __autoload($class) {
if (substr($class,0,3) !== 'CI_') {
if (file_exists($file = APPPATH.'core/'.$class.".php")) {
include $file;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment