Skip to content

Instantly share code, notes, and snippets.

@maemichi-monosense
Created December 27, 2018 10:33
Show Gist options
  • Save maemichi-monosense/b857fd967cf02a4fd278ec8744c86a36 to your computer and use it in GitHub Desktop.
Save maemichi-monosense/b857fd967cf02a4fd278ec8744c86a36 to your computer and use it in GitHub Desktop.
PHP dev server
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'
<h1>PHP dev server</h1>
<a href='/phpinfo'>PHP info</a>
<?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; ?>
@maemichi-monosense
Copy link
Author

TODO

  • gateway ip addr

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment