You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

24 lines
1.1 KiB

  1. <?php
  2. use Symfony\Component\Dotenv\Dotenv;
  3. require dirname(__DIR__).'/vendor/autoload.php';
  4. if (!class_exists(Dotenv::class)) {
  5. throw new LogicException('Please run "composer require symfony/dotenv" to load the ".env" files configuring the application.');
  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') && (!isset($env['APP_ENV']) || ($_SERVER['APP_ENV'] ?? $_ENV['APP_ENV'] ?? $env['APP_ENV']) === $env['APP_ENV'])) {
  10. (new Dotenv(false))->populate($env);
  11. } else {
  12. // load all the .env files
  13. (new Dotenv(false))->loadEnv(dirname(__DIR__).'/.env');
  14. }
  15. $_SERVER += $_ENV;
  16. $_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = ($_SERVER['APP_ENV'] ?? $_ENV['APP_ENV'] ?? null) ?: 'dev';
  17. $_SERVER['APP_DEBUG'] = $_SERVER['APP_DEBUG'] ?? $_ENV['APP_DEBUG'] ?? 'prod' !== $_SERVER['APP_ENV'];
  18. $_SERVER['APP_DEBUG'] = $_ENV['APP_DEBUG'] = (int) $_SERVER['APP_DEBUG'] || filter_var($_SERVER['APP_DEBUG'], FILTER_VALIDATE_BOOLEAN) ? '1' : '0';