index.php 1.27 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 22 23 24 25 26

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

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