Skip to content

Commit

Permalink
Merge pull request #171 from acasademont/fix_symfony5_depreactions
Browse files Browse the repository at this point in the history
Fix Symfony 5.1 Dotenv component deprecations
  • Loading branch information
andig authored Jun 8, 2020
2 parents 580622c + 5159de6 commit fd7d00c
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions Bootstraps/Symfony.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Symfony\Contracts\Service\ResetInterface;
use function PHPPM\register_file;
use Symfony\Component\HttpKernel\KernelInterface;
use Symfony\Component\Dotenv\Dotenv;

/**
* A default bootstrap for the Symfony framework
Expand Down Expand Up @@ -53,8 +54,13 @@ public function getApplication()
}

// environment loading as of Symfony 3.3
if (!getenv('APP_ENV') && class_exists('Symfony\Component\Dotenv\Dotenv') && file_exists(realpath('.env'))) {
(new \Symfony\Component\Dotenv\Dotenv(true))->load(realpath('.env'));
if (!getenv('APP_ENV') && class_exists(Dotenv::class) && file_exists(realpath('.env'))) {
//Symfony >=5.1 compatibility
if (method_exists(Dotenv::class, 'usePutenv')) {
(new Dotenv())->usePutenv()->load(realpath('.env'));
} else {
(new Dotenv(true))->load(realpath('.env'));
}
}

$namespace = getenv('APP_KERNEL_NAMESPACE') ?: '\App\\';
Expand Down

0 comments on commit fd7d00c

Please sign in to comment.