argument('domain'); // adding flags $domainFlags = ''; // add file for domain $saved = []; // create flags foreach($domains as $domain) { $domainFlags .= '-d '.$domain.' '; $saved[$domain] = '/etc/letsencrypt/live/'.$domain.'/fullchain.pem'; } exec('certbot --non-interactive --agree-tos -m '.$this->argument('email').' --nginx '.$domainFlags, $output); $this->line(implode("\n", $output)); foreach($saved as $domain => $file) { if (file_exists($file)) { $this->info($domain.'...Success!'); } else { $this->error($domain.'...Failed!'); } } } }