Skip to content

Instantly share code, notes, and snippets.

@iamdual
Last active June 28, 2020 18:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iamdual/dbd2daacdde1339b434b7fb2026ac3df to your computer and use it in GitHub Desktop.
Save iamdual/dbd2daacdde1339b434b7fb2026ac3df to your computer and use it in GitHub Desktop.
Built-in PHP server skeleton for development environment
<?php php_sapi_name() === "cli-server" or die("Development only.");
$__config = [
"document_root" => __DIR__ . "/public/",
"default_file" => "index.php"
];
if (is_file($__config["document_root"].$_SERVER["REQUEST_URI"])) {
header("Content-type: " . mime_content_type($__config["document_root"].$_SERVER["REQUEST_URI"]));
readfile($__config["document_root"].$_SERVER["REQUEST_URI"]);
exit;
}
require $__config["document_root"] . $__config["default_file"];
php -S localhost:8081 server.php
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment