Last active
March 5, 2016 15:29
-
-
Save endel/d89a7d82e44f534d449e to your computer and use it in GitHub Desktop.
Simple development server for running PHP projects without having to configure a web application server (nginx, apache, etc)
This file contains hidden or 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 | |
| // | |
| // Development server. | |
| // | |
| // Requires PHP 5.4+, with built-in web-server feature: | |
| // http://php.net/manual/en/features.commandline.webserver.php | |
| // | |
| // Run it through console via: | |
| // $ php -S localhost:8000 ./dev_server.php | |
| // | |
| $root_path = getcwd() . '/'; | |
| if (file_exists($root_path . $_SERVER['REQUEST_URI'])) { | |
| if (preg_match('/\.php$/', $_SERVER['REQUEST_URI'])) { | |
| require($root_path . $_SERVER['REQUEST_URI']); | |
| } else { | |
| return false; | |
| } | |
| } else { | |
| require('index.php'); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment