public function fire() { $defaultKey = di('config')->get('app.key'); $key = Str::random(32); $path = base_path('.env'); if (file_exists($path)) { file_put_contents($path, str_replace($defaultKey, $key, file_get_contents($path))); // set the new application key to config service. di('config')->set('app.key', $key); } $this->callOptimize(); $this->showInfo($key); }