<?php
require_once dirname(__DIR__) . '/vendor/autoload_runtime.php';
use App\Kernel;
use Symfony\Component\Dotenv\Dotenv;
//we use Dotenv package to get variable of .env with syntax of getenv, example: getenv('APP_ENV')
$dotenv = new Dotenv();
$dotenv->usePutenv();
$dotenv->loadEnv(__DIR__.'/../.env');
return function (array $context) {
if (in_array($context['APP_ENV'], ['dev', 'prod'])) {
header('Access-Control-Allow-Origin: *');
header("Access-Control-Allow-Headers: *");
header("Access-Control-Allow-Methods: *");
if ($_SERVER['REQUEST_METHOD'] === "OPTIONS") {
header("Access-Control-Allow-Credentials: true");
header("Access-Control-Max-Age: 1728000");
header("Content-Type: text/plain charset=UTF-8");
header("Content-Length: 0");
die;
}
}
return new Kernel($context['APP_ENV'], (bool)$context['APP_DEBUG']);
};