black-sheep-bluff/app/Core/Kernel.php
2026-09-18 06:46:56 +02:00

46 lines
1.4 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?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();
}
}