Skip to content

Commit e4cbc4a

Browse files
committed
Add config/bootstrap file
1 parent 6f4c492 commit e4cbc4a

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

config/bootstrap.php

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
use Symfony\Component\Dotenv\Dotenv;
4+
5+
require dirname(__DIR__).'/vendor/autoload.php';
6+
7+
if (!class_exists(Dotenv::class)) {
8+
throw new LogicException('Please run "composer require symfony/dotenv" to load the ".env" files configuring the application.');
9+
}
10+
11+
// Load cached env vars if the .env.local.php file exists
12+
// Run "composer dump-env prod" to create it (requires symfony/flex >=1.2)
13+
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'])) {
14+
(new Dotenv(false))->populate($env);
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';

0 commit comments

Comments
 (0)