/** * The name and signature of the console command. * * @var string */ protected$signature = 'key:generate {--show : Display the key instead of modifying files} {--force : Force the operation to run when in production}';
/** * The console command description. * * @var string */ protected$description = 'Set the application key';
if ($this->option('show')) { return$this->line('<comment>'.$key.'</comment>'); }
// Next, we will replace the application key in the environment file so it is // automatically setup for this developer. This key gets generated using a // secure random byte generator and is later base64 encoded for storage. if (! $this->setKeyInEnvironmentFile($key)) { return; }
$this->laravel['config']['app.key'] = $key;
$this->info('Application key set successfully.'); }
/** * Generate a random key for the application. * * @return string */ protectedfunctiongenerateRandomKey() { return'base64:'.base64_encode( Encrypter::generateKey($this->laravel['config']['app.cipher']) ); }