vd/bootstrap/app.php
2019-03-01 20:53:21 +08:00

45 lines
1.3 KiB
PHP

<?php
if (version_compare(phpversion(), '7.1', '>=')) {
ini_set('serialize_precision', -1);
}
require_once __DIR__.'/../vendor/autoload.php';
if (isset($_SERVER['REQUEST_METHOD']) && strtoupper($_SERVER['REQUEST_METHOD']) === 'OPTIONS') {
$options = require __DIR__.'/../config/cors.php';
$request = \Symfony\Component\HttpFoundation\Request::createFromGlobals();
$cors = new \Asm89\Stack\CorsService($options);
if ($cors->isPreflightRequest($request)) {
$response = $cors->handlePreflightRequest($request);
exit($response->send());
}
}
try {
(new Dotenv\Dotenv(__DIR__.'/../'))->load();
} catch (Dotenv\Exception\InvalidPathException $e) {
//
}
/*
|--------------------------------------------------------------------------
| Create The Application
|--------------------------------------------------------------------------
|
| Here we will load the environment and create the application instance
| that serves as the central piece of this framework. We'll use this
| application as an "IoC" container and router for this framework.
|
*/
$app = new Laravel\Lumen\Application(
realpath(__DIR__.'/../')
);
$app->register(App\Providers\AppServiceProvider::class);
$app->register(App\Providers\EventServiceProvider::class);
return $app;