Files
tinker_tickets/tests/ui/router.php
T

23 lines
596 B
PHP
Raw Normal View History

<?php
/**
* Router for PHP's built-in server in the UI tests (tests/ui/stack.sh): static
* files are served as-is, PHP files run, everything else goes to index.php, as
* nginx's try_files does in production.
*/
if (php_sapi_name() !== 'cli-server') {
http_response_code(404);
exit;
}
$path = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
$file = $_SERVER['DOCUMENT_ROOT'] . $path;
if ($path !== '/' && is_file($file)) {
if (!str_ends_with($file, '.php')) {
return false;
}
require $file;
return true;
}
require $_SERVER['DOCUMENT_ROOT'] . '/index.php';