public/index.php line 35

Open in your IDE?
  1. <?php
  2. //@todo this should be only temporary
  3. ini_set('max_execution_time'300);
  4. ini_set('memory_limit''128M');
  5. ini_set('session.gc_maxlifetime'7200);
  6. use App\Kernel;
  7. use Symfony\Component\Debug\Debug;
  8. use Symfony\Component\Dotenv\Dotenv;
  9. use Symfony\Component\HttpFoundation\Request;
  10. require __DIR__.'/../vendor/autoload.php';
  11. // The check is to ensure we don't use .env in production
  12. if (!isset($_SERVER['APP_ENV'])) {
  13.     if (!class_exists(Dotenv::class)) {
  14.         throw new \RuntimeException('APP_ENV environment variable is not defined. You need to define environment variables for configuration or add "symfony/dotenv" as a Composer dependency to load variables from a .env file.');
  15.     }
  16.     (new Dotenv(true))->load(__DIR__.'/../.env');
  17. }
  18. $env $_SERVER['APP_ENV'] ?? 'dev';
  19. $debug $_SERVER['APP_DEBUG'] ?? ('prod' !== $env);
  20. if ($env !== 'dev' && (empty($_SERVER['HTTPS']) || $_SERVER['HTTPS'] === "off")) {
  21.     $location 'https://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
  22.     header('HTTP/1.1 301 Moved Permanently');
  23.     header('Location: '.$location);
  24.     exit;
  25. }
  26. umask(0000);
  27. if ($debug) {
  28.     Debug::enable();
  29. }
  30. if ($trustedProxies $_SERVER['TRUSTED_PROXIES'] ?? false) {
  31.     Request::setTrustedProxies(explode(','$trustedProxies), Request::HEADER_X_FORWARDED_ALL Request::HEADER_X_FORWARDED_HOST);
  32. }
  33. if ($trustedHosts $_SERVER['TRUSTED_HOSTS'] ?? false) {
  34.     Request::setTrustedHosts(explode(','$trustedHosts));
  35. }
  36. $kernel = new Kernel($env$debug);
  37. $request Request::createFromGlobals();
  38. $response $kernel->handle($request);
  39. $response->send();
  40. $kernel->terminate($request$response);