When debug is true: enable Twig debug mode (dump(), auto_reload, DebugExtension), and stop caching sidecar-less pages — Renderer skips the cache write, the dev router skips serving cache files, and bootstrap clears stale cache on the first request that reaches PHP. Also update docs: new Debug mode section on the config page, cache- opt-out notes (debug + empty index.php sidecar) on the caching page, and correct the Sass build target to App/css/main.css in AGENTS.md and the styling page. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011FZQHKxu24mvojrJDwhWVS
38 lines
1.5 KiB
PHP
38 lines
1.5 KiB
PHP
<?php
|
|
// Dev-only router for `php -S`, mimicking the .htaccess rules for local testing.
|
|
// Not used in production (Apache reads .htaccess directly).
|
|
|
|
$uri = urldecode(parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH));
|
|
|
|
if ($uri !== '/' && str_ends_with($uri, '/')) {
|
|
// Preserve the query string across the canonical redirect — Apache's
|
|
// .htaccess does this automatically, so dev must too or post/redirect
|
|
// flows like /contact/?sent=1 lose their flags under `php -S`.
|
|
$query = parse_url($_SERVER['REQUEST_URI'], PHP_URL_QUERY);
|
|
header('Location: ' . rtrim($uri, '/') . ($query !== null ? '?' . $query : ''), true, 301);
|
|
exit;
|
|
}
|
|
|
|
$file = __DIR__ . $uri;
|
|
if ($uri !== '/' && (is_file($file) || is_dir($file))) {
|
|
return false; // let the built-in server handle real files/dirs (css, cache)
|
|
}
|
|
|
|
// Mirror .htaccess's "serve the pre-rendered static file, bypassing PHP"
|
|
// rule — but skip it when debug is on, so sidecar-less pages render fresh
|
|
// on every request (Renderer also stops writing the cache in that mode).
|
|
$novaconiumConfig = require __DIR__ . '/../novaconium/config.php';
|
|
$appConfigFile = __DIR__ . '/../App/config.php';
|
|
$config = is_file($appConfigFile)
|
|
? array_merge($novaconiumConfig, require $appConfigFile)
|
|
: $novaconiumConfig;
|
|
$debug = (bool) $config['debug'];
|
|
|
|
$cacheFile = __DIR__ . '/cache' . $uri . '/index.html';
|
|
if (!$debug && is_file($cacheFile)) {
|
|
readfile($cacheFile);
|
|
return true;
|
|
}
|
|
|
|
require __DIR__ . '/index.php';
|