<?php

declare(strict_types=1);

/**
 * Front controller — the single entry point for all web requests.
 *
 * Apache/Nginx/LiteSpeed rewrite every non-file request here (see .htaccess).
 * It boots the autoloader, constructs the Kernel and dispatches the request.
 */

use BotGuard\Core\Kernel;
use BotGuard\Core\Request;

$basePath = dirname(__DIR__);

// Prefer Composer's optimized autoloader; fall back to the bundled PSR-4 loader
// so the platform also runs on hosts without `composer install`.
$composer = $basePath . '/vendor/autoload.php';
if (is_file($composer)) {
    require $composer;
} else {
    require $basePath . '/app/Core/Autoloader.php';
    BotGuard\Core\Autoloader::register();
}

$kernel = new Kernel($basePath);
$response = $kernel->handle(Request::capture());
$response->send();
