Version 1
[yaffs-website] / vendor / drush / drush / commands / runserver / d8-rs-router.php
1 <?php
2
3 // Get a $_SERVER key, or equivalent environment variable
4 // if it is not set in $_SERVER.
5 function runserver_env($key) {
6   if (isset($_SERVER[$key])) {
7     return $_SERVER[$key];
8   }
9   else {
10     return getenv($key);
11   }
12 }
13
14 $url = parse_url($_SERVER["REQUEST_URI"]);
15 if (file_exists('.' . $url['path'])) {
16   // Serve the requested resource as-is.
17   return FALSE;
18 }
19
20 // We set the base_url so that Drupal generates correct URLs for runserver
21 // (e.g. http://127.0.0.1:8888/...), but can still select and serve a specific
22 // site in a multisite configuration (e.g. http://mysite.com/...).
23 $base_url = runserver_env('RUNSERVER_BASE_URL');
24
25 // The built in webserver incorrectly sets $_SERVER['SCRIPT_NAME'] when URLs
26 // contain multiple dots (such as config entity IDs) in the path. Since this is
27 // a virtual resource, served by index.php set the script name explicitly.
28 // See https://github.com/drush-ops/drush/issues/2033 for more information.
29 $_SERVER['SCRIPT_NAME'] = '/index.php';
30
31 // Include the main index.php and let Drupal take over.
32 // n.b. Drush sets the cwd to the Drupal root during bootstrap.
33 include 'index.php';