<?php
declare(strict_types=1);

// php -S dev server: let real static files through, never raw PHP internals
if (PHP_SAPI === 'cli-server') {
    $p = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH) ?: '/';
    $f = __DIR__ . $p;
    if ($p !== '/' && is_file($f) && !str_ends_with($p, '.php') && !preg_match('#^/(app|sql|tests|docs|legacy|data|views)(/|$)#', $p)) return false;
}
define('ROOT', __DIR__);
if (PHP_SAPI === 'cli-server' && (parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH) ?: '') === '/install.php') { require ROOT . '/install.php'; return; }
require ROOT . '/app/bootstrap.php';
// the dev server has no .htaccess: mirror its deny rules
if (PHP_SAPI === 'cli-server' && preg_match('#^/(app|sql|tests|docs|legacy|data|views)(/|$)|^/config(\.sample)?\.php$#', request_path())) abort(403);
dispatch();
