## if you want to load eloquent model from global context; ## $ci_path = realpath(__DIR__ . 'codeigniter_path') . '/'; ## $ci_system_path = $ci_path . 'system/'; ## define('BASEPATH', str_replace('\\', '/', $ci_system_path)); function load_model($model) { global $ci_path; $_ci_model_paths = [ $ci_path . 'application/' ]; $model = ucfirst(strtolower($model)); $path = ''; foreach ($_ci_model_paths as $mod_path) { if ( ! file_exists($mod_path.'models/'.$path.$model.'.php')) { continue; } require_once($mod_path.'models/'.$path.$model.'.php'); $_ci_models[] = $name; return new $model(); } }