<?php
/**
 * Natovia — ONE entry point for every domain.
 * php -S 127.0.0.1:8080 -t public public/index.php
 */

define('ROOT_PATH', dirname(__DIR__));

// Built-in dev server: let it serve real files in public/ directly — but only when public/ is
// the document root. IDEs (PhpStorm) often start it with the project folder as the root; then
// returning false would look for /assets/... in the wrong folder, so the router serves them
// (see the /assets route in app/router.php).
if (PHP_SAPI === 'cli-server') {
    $file = __DIR__ . parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
    $docRoot = realpath($_SERVER['DOCUMENT_ROOT'] ?? '') ?: '';
    if ($docRoot === realpath(__DIR__) && $file !== __DIR__ . '/' && is_file($file) && !str_ends_with($file, '.php')) {
        return false;
    }
}

require ROOT_PATH . '/app/bootstrap.php';
require ROOT_PATH . '/app/router.php';
