PHP built-in server shows index page instead of static file

The cause was the PHP built-in development server being 'dumb'.

I had to include this check as the very first thing in the index.php file.

// To help the built-in PHP dev server, check if the request was actually for
// something which should probably be served as a static file
if (PHP_SAPI == 'cli-server') {
    $url  = parse_url($_SERVER['REQUEST_URI']);
    $file = __DIR__ . $url['path'];
    if (is_file($file)) return false;
}

Source: https://github.com/slimphp/Slim-Skeleton/blob/master/public/index.php

Tags:

Php

Twig

Slim