d8-rs-router.php

  1. 8.0.x commands/runserver/d8-rs-router.php
  2. 7.x commands/runserver/d8-rs-router.php
  3. master commands/runserver/d8-rs-router.php

Functions

Namesort descending Description
runserver_env

File

commands/runserver/d8-rs-router.php
View source
  1. <?php
  2. // Get a $_SERVER key, or equivalent environment variable
  3. // if it is not set in $_SERVER.
  4. function runserver_env($key) {
  5. if (isset($_SERVER[$key])) {
  6. return $_SERVER[$key];
  7. }
  8. else {
  9. return getenv($key);
  10. }
  11. }
  12. $url = parse_url($_SERVER["REQUEST_URI"]);
  13. if (file_exists('.' . $url['path'])) {
  14. // Serve the requested resource as-is.
  15. return FALSE;
  16. }
  17. // Populate the "q" query key with the path, skip the leading slash.
  18. $_GET['q'] = $_REQUEST['q'] = substr($url['path'], 1);
  19. // We set the base_url so that Drupal generates correct URLs for runserver
  20. // (e.g. http://127.0.0.1:8888/...), but can still select and serve a specific
  21. // site in a multisite configuration (e.g. http://mysite.com/...).
  22. $base_url = runserver_env('RUNSERVER_BASE_URL');
  23. // Include the main index.php and let core take over.
  24. // n.b. Drush sets the cwd to the Drupal root during bootstrap.
  25. include 'index.php';