public/index.php line 3

Open in your IDE?
  1. <?php
  2. require_once dirname(__DIR__) . '/vendor/autoload_runtime.php';
  3. use App\Kernel;
  4. use Symfony\Component\Dotenv\Dotenv;
  5. //we use Dotenv package to get variable of .env with syntax of getenv, example: getenv('APP_ENV')
  6. $dotenv = new Dotenv();
  7. $dotenv->usePutenv();
  8. $dotenv->loadEnv(__DIR__.'/../.env');
  9. return function (array $context) {
  10.     if (in_array($context['APP_ENV'], ['dev''prod'])) {
  11.         header('Access-Control-Allow-Origin: *');
  12.         header("Access-Control-Allow-Headers: *");
  13.         header("Access-Control-Allow-Methods: *");
  14.         if ($_SERVER['REQUEST_METHOD'] === "OPTIONS") {
  15.             header("Access-Control-Allow-Credentials: true");
  16.             header("Access-Control-Max-Age: 1728000");
  17.             header("Content-Type: text/plain charset=UTF-8");
  18.             header("Content-Length: 0");
  19.             die;
  20.         }
  21.     }
  22.     return new Kernel($context['APP_ENV'], (bool)$context['APP_DEBUG']);
  23. };