info('.env berhasil dibuat dari .env.example'); } $dbConnection = $this->choice( 'Pilih database yang digunakan', ['mysql', 'pgsql', 'sqlite'], 1 // default pgsql ); $dbHost = $this->ask('Masukkan IP Address / Host', '127.0.0.1'); $dbPort = $this->ask( 'Masukkan Port Database', $dbConnection === 'mysql' ? '3306' : '5432' ); $dbDatabase = $this->ask('Masukkan Nama Database', 'parkir'); $dbUsername = $this->ask('Masukkan Username Database', 'postgres'); $dbPassword = $this->secret('Masukkan Password Database'); $env = file_get_contents($envFile); $replacements = [ 'APP_DEBUG' => 'true', 'DB_CONNECTION' => $dbConnection, 'DB_HOST' => $dbHost, 'DB_PORT' => $dbPort, 'DB_DATABASE' => $dbDatabase, 'DB_USERNAME' => $dbUsername, 'DB_PASSWORD' => $dbPassword, ]; foreach ($replacements as $key => $value) { $env = preg_replace( "/^{$key}=.*/m", "{$key}={$value}", $env ); } file_put_contents($envFile, $env); $this->info('Konfigurasi .env berhasil diperbarui.'); $this->newLine(); $this->table( ['Key', 'Value'], [ ['DB_CONNECTION', $dbConnection], ['DB_HOST', $dbHost], ['DB_PORT', $dbPort], ['DB_DATABASE', $dbDatabase], ['DB_USERNAME', $dbUsername], ] ); $this->newLine(); if ($this->confirm('Jalankan php artisan key:generate?', true)) { Artisan::call('key:generate'); $this->line(Artisan::output()); } // if ($this->confirm('Jalankan php artisan migrate?', false)) { // Artisan::call('migrate', ['--force' => true]); // $this->line(Artisan::output()); // } if ($this->confirm('Jalankan php artisan config:clear?', true)) { Artisan::call('config:clear'); $this->line(Artisan::output()); } if ($this->confirm('Jalankan php artisan cache:clear?', true)) { Artisan::call('cache:clear'); $this->line(Artisan::output()); } $this->info('Setup selesai.'); return Command::SUCCESS; } }