<?php

// Load all the classes we need
require __DIR__ . "/brain/Loader.php";
require __DIR__ . "/vendor/autoload.php";

use brain\controllers\RouteController;

// Capture URI
$request = parse_url($_SERVER["REQUEST_URI"], PHP_URL_PATH);

// Strip leading /
//$request = ltrim($request, " / ");

$route = new RouteController();

// Match route and dispatch
try {
    $route->start($request);
} catch (Exception $e) {
    // No route found
    http_response_code(404);
    require __DIR__ . "/src/views/404.php";
}
