]> Raphaƫl G. Git Repositories - airlibre/blob - config/bootstrap.php
Add public bundles symlinks
[airlibre] / config / bootstrap.php
1 <?php
2
3 use Symfony\Component\Dotenv\Dotenv;
4
5 require dirname(__DIR__).'/vendor/autoload.php';
6
7 // Load cached env vars if the .env.local.php file exists
8 // Run "composer dump-env prod" to create it (requires symfony/flex >=1.2)
9 if (is_array($env = @include dirname(__DIR__).'/.env.local.php') && ($_SERVER['APP_ENV'] ?? $_ENV['APP_ENV'] ?? $env['APP_ENV']) === $env['APP_ENV']) {
10 foreach ($env as $k => $v) {
11 $_ENV[$k] = $_ENV[$k] ?? (isset($_SERVER[$k]) && 0 !== strpos($k, 'HTTP_') ? $_SERVER[$k] : $v);
12 }
13 } elseif (!class_exists(Dotenv::class)) {
14 throw new RuntimeException('Please run "composer require symfony/dotenv" to load the ".env" files configuring the application.');
15 } else {
16 // load all the .env files
17 (new Dotenv(false))->loadEnv(dirname(__DIR__).'/.env');
18 }
19
20 $_SERVER += $_ENV;
21 $_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = ($_SERVER['APP_ENV'] ?? $_ENV['APP_ENV'] ?? null) ?: 'dev';
22 $_SERVER['APP_DEBUG'] = $_SERVER['APP_DEBUG'] ?? $_ENV['APP_DEBUG'] ?? 'prod' !== $_SERVER['APP_ENV'];
23 $_SERVER['APP_DEBUG'] = $_ENV['APP_DEBUG'] = (int) $_SERVER['APP_DEBUG'] || filter_var($_SERVER['APP_DEBUG'], FILTER_VALIDATE_BOOLEAN) ? '1' : '0';