| 1 | <?php |
| 2 | declare(strict_types=1); |
| 3 | // php -S 127.0.0.1:8080 -t build build/router.php |
| 4 | $uri = urldecode(parse_url($_SERVER['REQUEST_URI'] ?? '/', PHP_URL_PATH) ?? '/'); |
| 5 | $file = __DIR__ . $uri; |
| 6 | if ($uri !== '/' && is_file($file)) { |
| 7 | return false; |
| 8 | } |
| 9 | if (str_ends_with($uri, '.php') && is_file($file)) { |
| 10 | require $file; |
| 11 | return true; |
| 12 | } |
| 13 | if (is_file(__DIR__ . '/index.html')) { |
| 14 | header('Content-Type: text/html; charset=utf-8'); |
| 15 | readfile(__DIR__ . '/index.html'); |
| 16 | return true; |
| 17 | } |
| 18 | return false; |
projects-timfalken-com allianties