/** * Set the application key in the environment file. * * @param string $key */ protected function setKeyInEnvironmentFile($key) { $path = $this->laravel->environmentFilePath(); if (file_exists($path)) { file_put_contents($path, str_replace('APP_KEY=' . $this->laravel['config']['app.key'], 'APP_KEY=' . $key, file_get_contents($path))); } else { touch($path); file_put_contents($path, 'APP_KEY=' . $key); } }