public/index.php line 46

Open in your IDE?
  1. <?php
  2. use App\Kernel;
  3. use Symfony\Component\Debug\Debug;
  4. use Symfony\Component\Dotenv\Dotenv;
  5. use Symfony\Component\HttpFoundation\Request;
  6. require __DIR__.'/../vendor/autoload.php';
  7. header("Access-Control-Allow-Origin: *");
  8. header("Access-Control-Allow-Headers: XMLHttpRequest, X_API_KEY, Origin, X_Requested_with, Content-Type, Accept, Access-Control-Request-Method, authorization");
  9. header("Access-Control-Allow-Methods: GET,POST,OPTIONS,PUT,DELETE");
  10. header("Allow: GET, POST, OPTIONS, PUT, DELETE");
  11. $method $_SERVER["REQUEST_METHOD"];
  12. if ($method == "OPTIONS") {
  13.     die();
  14. }
  15. // The check is to ensure we don't use .env in production
  16. if (!isset($_SERVER['APP_ENV'])) {
  17.     if (!class_exists(Dotenv::class)) {
  18.         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.');
  19.     }
  20.     (new Dotenv())->load(__DIR__.'/../.env');
  21. }
  22. $env $_SERVER['APP_ENV'] ?? 'dev';
  23. $debug = (bool) ($_SERVER['APP_DEBUG'] ?? ('prod' !== $env));
  24. if ($debug) {
  25.     umask(0000);
  26.     Debug::enable();
  27. }
  28. if ($trustedProxies $_SERVER['TRUSTED_PROXIES'] ?? false) {
  29.     Request::setTrustedProxies(explode(','$trustedProxies), Request::HEADER_X_FORWARDED_ALL Request::HEADER_X_FORWARDED_HOST);
  30. }
  31. if ($trustedHosts $_SERVER['TRUSTED_HOSTS'] ?? false) {
  32.     Request::setTrustedHosts(explode(','$trustedHosts));
  33. }
  34. $kernel = new Kernel($env$debug);
  35. $request Request::createFromGlobals();
  36. $response $kernel->handle($request);
  37. $response->send();
  38. $kernel->terminate($request$response);