note 118912 deleted from features.commandline.webserver by cmb
| From: | cmb@php.net | Date: | Thu, 17 Sep 2020 07:46:00 +0000 |
| Subject: | note 118912 deleted from features.commandline.webserver by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-215134@lists.php.net to get a copy of this message | ||
Note Submitter: leandro at leandroleite dot info
----
when I need to up a server for develop with rewrite, I use it:
// php -S 0.0.0.0:8080 -file webServer.php
// webServer.php
<?php
if (preg_match('/\.css|\.js|\.jpg|\.png|\.map$/', $_SERVER['REQUEST_URI'],
$match)) {
$mimeTypes = [
'.css' => 'text/css',
'.js' => 'application/javascript',
'.jpg' => 'image/jpg',
'.png' => 'image/png',
'.map' => 'application/json'
];
$path = __DIR__ . $_SERVER['REQUEST_URI'];
if (is_file($path)) {
header("Content-Type: {$mimeTypes[$match[0]]}");
require $path;
exit;
}
}
require_once __DIR__.'/../app/bootstrap.php';