index.php 1.49 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\HttpKernel\Exception\HttpExceptionInterface;
14
use Symfony\Component\HttpFoundation\Request;
15
use Symfony\Component\HttpFoundation\Response;
16

17
$autoloader = require_once __DIR__ . '/core/vendor/autoload.php';
18

19
try {
20 21 22 23

  $request = Request::createFromGlobals();
  $kernel = DrupalKernel::createFromRequest($request, $autoloader, 'prod');
  $response = $kernel
24
      ->handle($request)
25 26 27
      // Handle the response object.
      ->prepare($request)->send();
  $kernel->terminate($request, $response);
28
}
29
catch (HttpExceptionInterface $e) {
30
  $response = new Response($e->getMessage(), $e->getStatusCode());
31 32
  $response->prepare($request)->send();
}
33
catch (Exception $e) {
34
  $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>';
35
  if (Settings::get('rebuild_access', FALSE)) {
36 37 38
    $rebuild_path = $GLOBALS['base_url'] . '/rebuild.php';
    $message .= " or run the <a href=\"$rebuild_path\">rebuild script</a>";
  }
39 40 41 42

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