laravel特殊功能代码片段集合

2023-06-07,,

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特殊功能代码片段集合.doc》

下载本文的Word格式文档,以方便收藏与打印。