This commit is contained in:
33333-33333 2026-08-08 17:41:30 +09:00
commit 1a3ba56d9a
123 changed files with 16018 additions and 9153 deletions

25
scripts/router.php Normal file
View file

@ -0,0 +1,25 @@
<?php
declare(strict_types=1);
// Router for PHP's built-in development server. Apache protects the legacy
// directory with .htaccess, but the built-in server ignores it completely.
$uri = rawurldecode((string)(parse_url((string)($_SERVER['REQUEST_URI'] ?? '/'), PHP_URL_PATH) ?: '/'));
$segments = array_values(array_filter(explode('/', str_replace('\\', '/', $uri)), static fn(string $part): bool => $part !== ''));
foreach ($segments as $segment) {
if (str_starts_with($segment, '.')) {
http_response_code(404);
header('Content-Type: text/plain; charset=utf-8');
echo "Not found\n";
return true;
}
}
$projectRoot = dirname(__DIR__);
$relative = ltrim($uri, '/');
$candidate = $projectRoot . ($relative === '' ? DIRECTORY_SEPARATOR . 'index.html' : DIRECTORY_SEPARATOR . $relative);
if (is_file($candidate)) return false;
http_response_code(404);
header('Content-Type: text/plain; charset=utf-8');
echo "Not found\n";
return true;

7
scripts/start_server.bat Normal file
View file

@ -0,0 +1,7 @@
@echo off
setlocal
set PORT=%~1
if "%PORT%"=="" set PORT=8000
for %%I in ("%~dp0..") do set "ROOT=%%~fI"
cd /d "%ROOT%"
php -S 127.0.0.1:%PORT% -t "%ROOT%" "%~dp0router.php"

6
scripts/start_server.sh Normal file
View file

@ -0,0 +1,6 @@
#!/usr/bin/env sh
set -eu
PORT="${1:-8000}"
SCRIPT_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
PROJECT_ROOT=$(CDPATH= cd -- "$SCRIPT_DIR/.." && pwd)
exec php -S "127.0.0.1:${PORT}" -t "$PROJECT_ROOT" "$SCRIPT_DIR/router.php"