1. 程式人生 > >laravel特殊功能代碼片段集合

laravel特殊功能代碼片段集合

交互 com hand src func all 分享圖片 where ()

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]]);
        }
    }

技術分享圖片

應用代碼中調用artisan

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

laravel特殊功能代碼片段集合