32 lines
903 B
PHP
32 lines
903 B
PHP
<?php
|
|
|
|
$DEFAULT_TO_LOAD = [
|
|
'Core\Collection',
|
|
'Core\BaseModel',
|
|
'Core\Router',
|
|
];
|
|
|
|
// Framework Autoload
|
|
spl_autoload_register(function ($class_name) {
|
|
$ds = DIRECTORY_SEPARATOR;
|
|
$class_path = str_replace('\\', $ds, $class_name);
|
|
// echo $class_name . "<br>";
|
|
|
|
try {
|
|
if(file_exists(__DIR__ . "{$ds}src{$ds}" . $class_path . '.php')) {
|
|
require_once __DIR__ . "{$ds}src{$ds}" . $class_path . '.php';
|
|
|
|
}else throw new Exception('Class ' . $class_name . ' not found in ' . __DIR__ . "{$ds}src{$ds}" . $class_path . '.php');
|
|
}
|
|
catch (Throwable $th) {
|
|
throw $th;
|
|
}
|
|
});
|
|
|
|
// Load all classes
|
|
foreach($DEFAULT_TO_LOAD as $class) {
|
|
if(!class_exists($class)) throw new Exception('Class ' . $class . ' not found');
|
|
}
|
|
|
|
// Vendor autoload
|
|
if(file_exists(__DIR__ . '/vendor/autoload.php')) require_once __DIR__ . '/vendor/autoload.php'; |