From 9c79267e2444b5df4c32123f62387b71953f0a26 Mon Sep 17 00:00:00 2001 From: Erik Gaal Date: Mon, 14 Feb 2022 14:31:01 +0100 Subject: [PATCH] Fix .env loading in development (#799) * Upgrade vlucas/phpdotenv to ^5.0 `Dotenv::create($paths)` was the syntax for releases before v4 * Remove vlucas/phpdotenv dependency and make it work with newer versions. --- composer.json | 1 - tests/TestCase.php | 6 +++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index b10f2d16..bf66e1f2 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,6 @@ "stancl/virtualcolumn": "^1.0" }, "require-dev": { - "vlucas/phpdotenv": "^3.3|^4.0|^5.0", "laravel/framework": "^6.0|^7.0|^8.0", "orchestra/testbench-browser-kit": "^4.0|^5.0|^6.0", "league/flysystem-aws-s3-v3": "~1.0", diff --git a/tests/TestCase.php b/tests/TestCase.php index bbc42489..d3e42ea1 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -48,7 +48,11 @@ abstract class TestCase extends \Orchestra\Testbench\TestCase protected function getEnvironmentSetUp($app) { if (file_exists(__DIR__ . '/../.env')) { - \Dotenv\Dotenv::create(__DIR__ . '/..')->load(); + if (method_exists(\Dotenv\Dotenv::class, 'createImmutable')) { + \Dotenv\Dotenv::createImmutable(__DIR__ . '/..')->load(); + } else { + \Dotenv\Dotenv::create(__DIR__ . '/..')->load(); + } } $app['config']->set([