Skip to content
Snippets Groups Projects
Select Git revision
  • 7ab95bb36de88488a6876b7b77451bc84cf56f15
  • main default protected
  • ci-test
  • v0.1.4
  • v0.1.3
  • v0.1.2
  • v0.1.1
  • v0.1.0
8 results

index.php

Blame
  • Christoph Reiter's avatar
    Reiter, Christoph authored
    7ab95bb3
    History
    index.php 1.13 KiB
    <?php
    
    declare(strict_types=1);
    
    use DBP\API\Server\Kernel;
    use Symfony\Component\ErrorHandler\Debug;
    use Symfony\Component\HttpFoundation\Request;
    
    // FPM renames all environment variables!
    if (isset($_SERVER['REDIRECT_APP_ENV'])) {
        $_SERVER['APP_ENV'] = $_SERVER['REDIRECT_APP_ENV'];
    }
    
    require dirname(__DIR__).'/config/bootstrap.php';
    
    if ($_SERVER['APP_DEBUG']) {
        umask(0000);
    
        Debug::enable();
    } else {
        // Set a dummy dumper handler to avoid left over dump() commands breaking production
        \Symfony\Component\VarDumper\VarDumper::setHandler(function ($var) {});
    }
    
    if ($trustedProxies = $_SERVER['TRUSTED_PROXIES'] ?? $_ENV['TRUSTED_PROXIES'] ?? false) {
        Request::setTrustedProxies(explode(',', $trustedProxies), Request::HEADER_X_FORWARDED_ALL ^ Request::HEADER_X_FORWARDED_HOST);
    }
    
    if ($trustedHosts = $_SERVER['TRUSTED_HOSTS'] ?? $_ENV['TRUSTED_HOSTS'] ?? false) {
        Request::setTrustedHosts([$trustedHosts]);
    }
    
    $kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']);
    $request = Request::createFromGlobals();
    $response = $kernel->handle($request);
    $response->send();
    $kernel->terminate($request, $response);