Change env storage

This commit is contained in:
René Preuß
2021-07-23 17:40:31 +02:00
parent d25046f545
commit 917af5c140
9 changed files with 48 additions and 24 deletions

View File

@@ -4,6 +4,7 @@ namespace App\Commands\Env;
use Dotenv\Dotenv;
use Illuminate\Support\Facades\App;
use Illuminate\Support\Facades\Storage;
use LaravelZero\Framework\Commands\Command;
class EnvSetCommand extends Command
@@ -31,11 +32,10 @@ class EnvSetCommand extends Command
*/
public function handle(): int
{
$envFilePath = App::environmentFilePath();
$this->info(sprintf("The following environment file is used: '%s'", $envFilePath));
$this->info(sprintf("The following environment file is used: '%s'", App::environmentFilePath()));
if (file_exists($envFilePath)) {
$env = Dotenv::parse(file_get_contents($envFilePath));
if (Storage::exists('.env')) {
$env = Dotenv::parse(Storage::get('.env'));
} else {
$this->warn('The environment file does not exist. Creating a new one...');
$env = [];
@@ -43,7 +43,7 @@ class EnvSetCommand extends Command
$env[strtoupper($this->argument('key'))] = $this->argument('value');
file_put_contents($envFilePath, self::updateEnv($env));
Storage::put('.env', self::updateEnv($env));
$this->info('The environment file was successfully updated.');