index.php 1.24 KB
Newer Older
1
<?php
Dries's avatar
Dries committed
2

3 4 5 6
/**
 * @file
 * The PHP page that serves all page requests on a Drupal installation.
 *
7
 * All Drupal code is released under the GNU General Public License.
8
 * See COPYRIGHT.txt and LICENSE.txt files in the "core" directory.
9 10
 */

11
use Drupal\Core\DrupalKernel;
12
use Drupal\Core\Site\Settings;
13
use Symfony\Component\HttpFoundation\Request;
14

15
$autoloader = require_once __DIR__ . '/core/vendor/autoload.php';
16

17
try {
18 19 20 21

  $request = Request::createFromGlobals();
  $kernel = DrupalKernel::createFromRequest($request, $autoloader, 'prod');
  $response = $kernel
22
      ->handle($request)
23 24 25
      // Handle the response object.
      ->prepare($request)->send();
  $kernel->terminate($request, $response);
26 27
}
catch (Exception $e) {
28
  $message = 'If you have just changed code (for example deployed a new module or moved an existing one) read <a href="http://drupal.org/documentation/rebuild">http://drupal.org/documentation/rebuild</a>';
29
  if (Settings::get('rebuild_access', FALSE)) {
30 31 32
    $rebuild_path = $GLOBALS['base_url'] . '/rebuild.php';
    $message .= " or run the <a href=\"$rebuild_path\">rebuild script</a>";
  }
33 34 35 36

  // Set the response code manually. Otherwise, this response will default to a
  // 200.
  http_response_code(500);
37
  print $message;
38 39
  throw $e;
}