Files
symfony-flex-recipes/behat/symfony2-extension/2.1/features/bootstrap/bootstrap.php
T
Ben Scott b3c5ff1df5 Add checks for Dotenv before calling it
`composer install --no-dev` fails when Dotenv is a dev dependency (which
it is in skeleton) and you're running in an environment without an
APP_ENV variable set.

Throw exception when no env variables are set and Dotenv is absent so
the user knows to either require DotEnv or specify an APP_ENV variable.
2017-11-23 15:39:39 +00:00

12 lines
464 B
PHP

<?php
use Symfony\Component\Dotenv\Dotenv;
// The check is to ensure we don't use .env in production
if (!isset($_SERVER['APP_ENV'])) {
if (!class_exists(Dotenv::class)) {
throw new \RuntimeException('APP_ENV environment variable is not defined. You need to define environment variables for configuration or add "symfony/dotenv" as a Composer dependency to load variables from a .env file.');
}
(new Dotenv())->load(__DIR__.'/../../.env');
}