Created
December 27, 2018 10:33
-
-
Save maemichi-monosense/b857fd967cf02a4fd278ec8744c86a36 to your computer and use it in GitHub Desktop.
PHP dev server
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
version: '3' | |
services: | |
# http://php.net/manual/ja/features.commandline.webserver.php | |
web: | |
image: php | |
command: php -S 0.0.0.0:8000 router.php | |
ports: | |
- '8000:8000' | |
working_dir: /web | |
volumes: | |
- './:/web' |
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
<h1>PHP dev server</h1> | |
<a href='/phpinfo'>PHP info</a> |
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 | |
namespace Route; | |
function match(string $regex): bool { | |
$uri = $_SERVER['REQUEST_URI']; | |
return preg_match($regex, $uri) === 1; | |
} | |
?> | |
<?php if (\Route\match('|/phpinfo|')): ?> | |
<?php phpinfo(); ?> | |
<?php else: ?> | |
<?= file_get_contents('index.html') ?> | |
<?php endif; ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
TODO