index.php 910 Bytes
Newer Older
Carl Schwan's avatar
Carl Schwan committed
1
<?php
2 3 4
// SPDX-FileCopyrightText: 2020 Carl Schwan <carl@carlschwan.eu>
//
// SPDX-License-Identifier: CC0-1.0
Carl Schwan's avatar
Carl Schwan committed
5

6 7 8
use App\Kernel;
use Symfony\Component\ErrorHandler\Debug;
use Symfony\Component\HttpFoundation\Request;
Carl Schwan's avatar
Carl Schwan committed
9

10
require __DIR__.'/config/bootstrap.php';
Carl Schwan's avatar
Carl Schwan committed
11

Carl Schwan's avatar
Carl Schwan committed
12
if ($_SERVER['APP_DEBUG']) {
Carl Schwan's avatar
Carl Schwan committed
13
    umask(0000);
14
    Debug::enable();
Carl Schwan's avatar
Carl Schwan committed
15
}
Carl Schwan's avatar
Carl Schwan committed
16

Carl Schwan's avatar
Carl Schwan committed
17 18 19 20
if (!file_exists('./var/cache')) {
    die();
}

21 22
if ($trustedProxies = $_SERVER['TRUSTED_PROXIES'] ?? $_ENV['TRUSTED_PROXIES'] ?? false) {
    Request::setTrustedProxies(explode(',', $trustedProxies), Request::HEADER_X_FORWARDED_ALL ^ Request::HEADER_X_FORWARDED_HOST);
Carl Schwan's avatar
Carl Schwan committed
23 24
}

25 26
if ($trustedHosts = $_SERVER['TRUSTED_HOSTS'] ?? $_ENV['TRUSTED_HOSTS'] ?? false) {
    Request::setTrustedHosts([$trustedHosts]);
Carl Schwan's avatar
Carl Schwan committed
27 28
}

Carl Schwan's avatar
Carl Schwan committed
29
$kernel = new Kernel('dev', true);
30 31 32 33
$request = Request::createFromGlobals();
$response = $kernel->handle($request);
$response->send();
$kernel->terminate($request, $response);