46 lines
1.4 KiB
PHP
46 lines
1.4 KiB
PHP
<?php
|
||
declare(strict_types=1);
|
||
|
||
/**
|
||
* Anwendungs-Kernel: registriert den Autoloader, lädt Helfer/Config,
|
||
* startet die Session und übergibt an den Router.
|
||
*
|
||
* Bewusst KEIN Composer nötig – ein schlanker Klassen-Autoloader, der die
|
||
* Standard-Verzeichnisse nach <ClassName>.php durchsucht (Dateiname == Klassenname).
|
||
*/
|
||
final class Kernel
|
||
{
|
||
public static function boot(string $basePath): void
|
||
{
|
||
define('BSB_BASE', $basePath);
|
||
define('BSB_UPLOADS', $basePath . '/public/uploads');
|
||
|
||
spl_autoload_register(static function (string $class) use ($basePath): void {
|
||
static $dirs = [
|
||
'app/Core',
|
||
'app/Database',
|
||
'app/Services',
|
||
'app/Controllers/Pages',
|
||
'app/Controllers/Api',
|
||
];
|
||
foreach ($dirs as $dir) {
|
||
$file = $basePath . '/' . $dir . '/' . $class . '.php';
|
||
if (is_file($file)) {
|
||
require $file;
|
||
return;
|
||
}
|
||
}
|
||
});
|
||
|
||
require $basePath . '/app/Support/helpers.php';
|
||
require $basePath . '/app/Database/migrations.php'; // globale Migrations-Definitionen
|
||
|
||
Config::load($basePath . '/config/config.php');
|
||
session_start();
|
||
|
||
(new Router(
|
||
require $basePath . '/app/routes/web.php',
|
||
require $basePath . '/app/routes/api.php'
|
||
))->dispatch();
|
||
}
|
||
}
|