Skip to content

Instantly share code, notes, and snippets.

@lleitep3
Created December 28, 2015 19:26
Show Gist options
  • Save lleitep3/7bfa7590801eed031e7d to your computer and use it in GitHub Desktop.
Save lleitep3/7bfa7590801eed031e7d to your computer and use it in GitHub Desktop.
script de web server quebra galho com rewrite para meu ambiente de dev
<?php
/**
* To run PHP server just paste the code bellow in root path :
* $ php -S 0.0.0.0:8080 -t ./public -f webServer.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';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment