废话不说,直接上代码namespace App\Console\Commands\Apollo;use Illuminate\Console\Command;use Illuminate\Support\Arr;use Org\Multilinguals\Apollo\Client\ApolloClient;class SyncCommand extends Command{ /** * The name and signature of the console command. * * @var string / protected $signature = ‘ue:apollo:sync’; /* * The console command description. * * @var string / protected $description = ‘阿波罗同步’; protected $config = []; /* * Create a new command instance. * * @return void / public function __construct() { parent::__construct(); } /* * Execute the console command. * * @return mixed */ public function handle() { while (true) { $this->doSync(); sleep(10); } } protected function doSync() { if (!$this->config) { $this->config = config(‘apollo’); } $server = Arr::get($this->config, ‘server’); $appid = Arr::get($this->config, ‘app_id’); $namespaces = Arr::get($this->config, ’namespace’); $apollo = new ApolloClient($server, $appid, $namespaces); $error = $apollo->start(); logger()->error(null, [’error’ => $error, ‘class’ => CLASS]); }}