20 define(
'DEBUG_ROUTER',
false);
28 $val = json_encode($val);
31 error_log(
'debug: '.$val);
40 if (php_sapi_name() ===
'cli-server') {
41 $debug(
"URI: {$_SERVER["REQUEST_URI
"]}");
42 if (preg_match(
'/^\/(index|get|static)\.php(\/)?/', $_SERVER[
"REQUEST_URI"])) {
46 $path = pathinfo($_SERVER[
"SCRIPT_FILENAME"]);
47 $url = pathinfo(substr($_SERVER[
"REQUEST_URI"], 1));
48 $route = parse_url(substr($_SERVER[
"REQUEST_URI"], 1))[
"path"];
49 $pathinfo = pathinfo($route);
50 $ext = isset($pathinfo[
'extension']) ? $pathinfo[
'extension'] :
'';
52 if (
$path[
"basename"] ==
'favicon.ico') {
58 if (strpos($route,
'pub/errors/default/') === 0) {
59 $route = preg_replace(
'#pub/errors/default/#',
'errors/default/', $route, 1);
62 $magentoPackagePubDir =
__DIR__.
"/../pub";
64 if (strpos($route,
'media/') === 0 ||
65 strpos($route,
'opt/') === 0 ||
66 strpos($route,
'static/') === 0 ||
67 strpos($route,
'errors/default/css/') === 0 ||
68 strpos($route,
'errors/default/images/') === 0
70 $origFile = $magentoPackagePubDir.
'/'.$route;
72 if (strpos($route,
'static/version') === 0) {
73 $route = preg_replace(
'#static/(version\d+/)?#',
'static/', $route, 1);
75 $file = $magentoPackagePubDir.
'/'.$route;
79 if (file_exists($origFile) || file_exists($file)) {
80 if (file_exists($origFile)) {
87 'js' =>
'application/javascript',
91 'svg' =>
'image/svg+xml',
92 'map' =>
'application/json',
93 'woff' =>
'application/x-woff',
94 'woff2' =>
'application/font-woff2',
95 'html' =>
'text/html',
98 if (isset($mimeTypes[$ext])) {
99 header(
"Content-Type: $mimeTypes[$ext]");
104 $debug(
'file does not exist');
105 if (strpos($route,
'static/') === 0) {
106 $route = preg_replace(
'#static/#',
'', $route, 1);
107 $_GET[
'resource'] = $route;
109 include($magentoPackagePubDir.
'/static.php');
111 }
elseif (strpos($route,
'media/') === 0) {
113 include($magentoPackagePubDir.
'/get.php');
118 $debug(
"thunk to index in $route");
119 include($magentoPackagePubDir.
'/index.php');
elseif(isset( $params[ 'redirect_parent']))
defined('TESTS_BP')||define('TESTS_BP' __DIR__