Newer
Older
/**
* @file
* The PHP page that serves all page requests on a Drupal installation.
*
Dries Buytaert
committed
* All Drupal code is released under the GNU General Public License.
Nate Lampton
committed
* See COPYRIGHT.txt and LICENSE.txt files in the "core" directory.
use Drupal\Core\DrupalKernel;
Alex Pott
committed
use Drupal\Core\Site\Settings;
Alex Pott
committed
use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
use Symfony\Component\HttpFoundation\Request;
Alex Pott
committed
use Symfony\Component\HttpFoundation\Response;
Alex Pott
committed
$autoloader = require_once __DIR__ . '/core/vendor/autoload.php';
Alex Pott
committed
try {
$request = Request::createFromGlobals();
$kernel = DrupalKernel::createFromRequest($request, $autoloader, 'prod');
$response = $kernel
Dries Buytaert
committed
->handle($request)
// Handle the response object.
->prepare($request)->send();
$kernel->terminate($request, $response);
Alex Pott
committed
}
Alex Pott
committed
catch (HttpExceptionInterface $e) {
$response = new Response($e->getMessage(), $e->getStatusCode());
Alex Pott
committed
$response->prepare($request)->send();
}
Alex Pott
committed
catch (Exception $e) {
$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>';
Alex Pott
committed
if (Settings::get('rebuild_access', FALSE)) {
$rebuild_path = $GLOBALS['base_url'] . '/rebuild.php';
$message .= " or run the <a href=\"$rebuild_path\">rebuild script</a>";
}
Angie Byron
committed
// Set the response code manually. Otherwise, this response will default to a
// 200.
http_response_code(500);
print $message;
Alex Pott
committed
throw $e;
}