<?php
define('ROOT_PATH', __DIR__);
if (session_status() === PHP_SESSION_NONE) {
    session_start();
}

ini_set('display_errors', 1);
error_reporting(E_ALL);

spl_autoload_register(function (string $class): void {
    $path = ROOT_PATH . '/' . str_replace('\\', '/', $class) . '.php';
    $path = str_replace('/App/', '/app/', $path); 

    if (file_exists($path)) {
        require_once $path;
    } else {
        die("Classe introuvable : {$class} → {$path}");
    }
});

$config = require ROOT_PATH . '/config.php';

if (session_status() === PHP_SESSION_NONE) {
    session_start();
}

$langService = new App\Core\Lang();
$router = new App\Core\Router($langService);
$router->dispatch();