From 1e120d3ec71cef1c55f834f7ebc786c6d219a273 Mon Sep 17 00:00:00 2001 From: Pig Fang Date: Fri, 19 Oct 2018 21:43:25 +0800 Subject: [PATCH] Fix reading .env file --- app/Http/Controllers/SetupController.php | 4 ++-- tests/SetupControllerTest.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/Http/Controllers/SetupController.php b/app/Http/Controllers/SetupController.php index ac8c11ad..a111036b 100644 --- a/app/Http/Controllers/SetupController.php +++ b/app/Http/Controllers/SetupController.php @@ -41,7 +41,7 @@ class SetupController extends Controller ); } - $content = File::get('.env'); + $content = File::get('..' . DIRECTORY_SEPARATOR . '.env'); $content = str_replace( 'DB_CONNECTION = '.env('DB_CONNECTION'), 'DB_CONNECTION = '.$request->input('type'), @@ -77,7 +77,7 @@ class SetupController extends Controller 'DB_PREFIX = '.$request->input('prefix'), $content ); - File::put('.env', $content); + File::put('..' . DIRECTORY_SEPARATOR . '.env', $content); return redirect('setup/info'); } diff --git a/tests/SetupControllerTest.php b/tests/SetupControllerTest.php index 555abbc0..82d2ccb9 100644 --- a/tests/SetupControllerTest.php +++ b/tests/SetupControllerTest.php @@ -59,8 +59,8 @@ class SetupControllerTest extends TestCase 'password' => env('DB_PASSWORD'), 'prefix' => '', ]; - File::shouldReceive('get')->with('.env')->andReturn(''); - File::shouldReceive('put')->with('.env', ''); + File::shouldReceive('get')->with('..' . DIRECTORY_SEPARATOR . '.env')->andReturn(''); + File::shouldReceive('put')->with('..' . DIRECTORY_SEPARATOR . '.env', ''); $this->post('/setup/database', $fake)->assertRedirect('/setup/info'); }