meetup-raffle-winner-picker/config/bootstrap.php

31 lines
1.1 KiB
PHP
Raw Normal View History

2020-04-29 19:20:38 +00:00
<?php
use Symfony\Component\Dotenv\Dotenv;
2020-04-29 23:20:57 +00:00
require dirname(__DIR__) . '/vendor/autoload.php';
2020-04-29 19:20:38 +00:00
if (!class_exists(Dotenv::class)) {
2020-04-29 23:20:57 +00:00
throw new LogicException(
'Please run "composer require symfony/dotenv" to load the ".env" files
configuring the application.'
);
2020-04-29 19:20:38 +00:00
}
// Load cached env vars if the .env.local.php file exists
// Run "composer dump-env prod" to create it (requires symfony/flex >=1.2)
2020-04-29 23:20:57 +00:00
if (
is_array($env = @include dirname(__DIR__) . '/.env.local.php') &&
(!isset($env['APP_ENV']) || ($_SERVER['APP_ENV'] ?? $_ENV['APP_ENV'] ?? $env['APP_ENV']) === $env['APP_ENV'])
) {
2020-04-29 19:20:38 +00:00
(new Dotenv(false))->populate($env);
} else {
// load all the .env files
2020-04-29 23:20:57 +00:00
(new Dotenv(false))->loadEnv(dirname(__DIR__) . '/.env');
2020-04-29 19:20:38 +00:00
}
$_SERVER += $_ENV;
$_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = ($_SERVER['APP_ENV'] ?? $_ENV['APP_ENV'] ?? null) ?: 'dev';
$_SERVER['APP_DEBUG'] = $_SERVER['APP_DEBUG'] ?? $_ENV['APP_DEBUG'] ?? 'prod' !== $_SERVER['APP_ENV'];
2020-04-29 23:20:57 +00:00
$_SERVER['APP_DEBUG'] = $_ENV['APP_DEBUG'] = (int) $_SERVER['APP_DEBUG']
|| filter_var($_SERVER['APP_DEBUG'], FILTER_VALIDATE_BOOLEAN) ? '1' : '0';