Last active
June 28, 2020 18:48
-
-
Save iamdual/dbd2daacdde1339b434b7fb2026ac3df to your computer and use it in GitHub Desktop.
Built-in PHP server skeleton for development environment
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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"]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
php -S localhost:8081 server.php |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment