public/index.php line 48

Open in your IDE?
  1. <?php
  2. use FMS\eLibreria\CmsBundle\Kernel;
  3. use FMS\eLibreria\CmsBundle\Runtime\RuntimeEnvironment;
  4. use Symfony\Component\Dotenv\Dotenv;
  5. use Symfony\Component\ErrorHandler\Debug;
  6. use Symfony\Component\HttpFoundation\Request;
  7. require __DIR__.'/../vendor/autoload.php';
  8. // The check is to ensure we don't use .env in production. The environment is read from the three sources a
  9. // SAPI may fill, because php -S leaves it in $_ENV alone and reading $_SERVER by itself served dev to an
  10. // installation started in prod (finding 9 of doc/verifactu/STATUS.md).
  11. $environment = RuntimeEnvironment::resolve($_SERVER, $_ENV, getenv());
  12. if (!$environment->isDefined()) {
  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. // putenv keeps getenv() working for the application code, as with Dotenv 4
  17. (new Dotenv())->usePutenv(true)->load(__DIR__.'/../.env');
  18. $environment = RuntimeEnvironment::resolve($_SERVER, $_ENV, getenv());
  19. }
  20. $env = $environment->name();
  21. $debug = $environment->isDebug();
  22. if ($debug) {
  23. umask(0000);
  24. Debug::enable();
  25. }
  26. if ($trustedProxies = $_SERVER['TRUSTED_PROXIES'] ?? false) {
  27. Request::setTrustedProxies(
  28. explode(',', $trustedProxies),
  29. Request::HEADER_X_FORWARDED_FOR | Request::HEADER_X_FORWARDED_PORT | Request::HEADER_X_FORWARDED_PROTO
  30. );
  31. }
  32. if ($trustedHosts = $_SERVER['TRUSTED_HOSTS'] ?? false) {
  33. Request::setTrustedHosts(explode(',', $trustedHosts));
  34. }
  35. $kernel = new Kernel($env, $debug);
  36. $request = Request::createFromGlobals();
  37. $response = $kernel->handle($request);
  38. $response->send();
  39. $kernel->terminate($request, $response);