30 lines
820 B
PHP
30 lines
820 B
PHP
<?php
|
|
|
|
// Load environment variables from .env file
|
|
$envFile = __DIR__ . '/.env';
|
|
if (file_exists($envFile)) {
|
|
$lines = file($envFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
|
|
foreach ($lines as $line) {
|
|
if (strpos($line, '#') === 0) continue;
|
|
if (strpos($line, '=') === false) continue;
|
|
list($key, $value) = explode('=', $line, 2);
|
|
$key = trim($key);
|
|
$value = trim($value);
|
|
if (!empty($key)) {
|
|
putenv("$key=$value");
|
|
$_ENV[$key] = $value;
|
|
}
|
|
}
|
|
}
|
|
|
|
// Router script for PHP built-in server
|
|
$uri = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
|
|
|
|
// Serve existing files directly
|
|
if ($uri !== '/' && file_exists(__DIR__ . $uri)) {
|
|
return false;
|
|
}
|
|
|
|
// Route everything through index.php
|
|
require __DIR__ . '/index.php';
|