Last active
March 16, 2016 14:28
-
-
Save Caffe1neAdd1ct/8d6e346c09d3d9861981 to your computer and use it in GitHub Desktop.
Router for Drupal 8 when using PHP InBuilt Webserver in Development
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 | |
$file = pathinfo($_SERVER["SCRIPT_FILENAME"]); | |
$mimeTypes = [ | |
'css' => 'text/css', | |
'js' => 'application/javascript', | |
'jpg' => 'image/jpg', | |
'png' => 'image/png', | |
'map' => 'application/json', | |
'svg' => 'image/svg+xml' | |
]; | |
if(array_key_exists($file['extension'], $mimeTypes)) { | |
$path = $_SERVER["DOCUMENT_ROOT"] . $_SERVER['REQUEST_URI']; | |
if (is_file($_SERVER["SCRIPT_FILENAME"])) { | |
header("Content-Type: {$mimeTypes[$file['extension']]}"); | |
readfile($_SERVER["SCRIPT_FILENAME"]); | |
exit; | |
} | |
} else { | |
require 'index.php'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment