console命令行交互

public function handle()
    {
        $name=$this->ask('What is your neme?');
        $city=$this->choice('Where is your city?',[
            'Beijing','Shanghai','Wuhan'
        ]);
        $age=$this->secret('How old are you?');

        if($this->confirm('output ok?')){
            $this->table(['NAME','CITY','AGE'],[[$name,$city,$age]]);
        }
    }

laravel特殊功能代码片段集合_第1张图片

应用代码中调用artisan

Artisan::call('command:test');