I have some tricks. I set a new configuration 'loading-cores' on config.php. You can set the config name whatever you want.
$config['loading-cores'] = array(
"load-my-cores" => TRUE,
/* core class(es) to be loaded, note: must be a php file type */
"my-cores" => ["APIResponder", "Anotherclass"]
);
my classes in core folder:
- APIResponder.php
- Anotherclass.php
Then open file ..system/core/CodeIgniter.php, try to find this snippet code:
if (file_exists(APPPATH.'core/'.$CFG->config['subclass_prefix'].'Controller.php')){
require_once APPPATH.'core/'.$CFG->config['subclass_prefix'].'Controller.php';}
Add lines of codes below to load your core classes, place it right after the snippet code above:
if(isset($CFG->config['loading-cores'])){
if($CFG->config['loading-cores']['load-my-cores'] && count($CFG->config['loading-cores']['my-cores']) > 0){
foreach ($$CFG->config['loading-cores']['my-cores'] as $core) {
if (file_exists(APPPATH."core/{$core}.php")){
require_once APPPATH."core/{$core}.php";
}
}
}
}
Set "load-my-cores" => FALSE if you don't need the core classes to be loaded.