聊聊?laravel怎么用命令來執行腳本

下面由laravel教程欄目帶大家介紹laravel怎么用命令來執行腳本,希望對大家有所幫助!

laravel 使用命令執行腳本

1.生成console文件

?php?artisan?make:console?TestConsole?--command=laravel:test

2.handle方法中編輯業務邏輯

<?php namespace AppConsoleCommands; use IlluminateConsoleCommand; class HelloLaravelAcademy extends Command {     /**      * The name and signature of the console command.      *      * @var string      */     protected $signature = &#39;laravel:test {name?}&#39;;     /**      * The console command description.      *      * @var string      */     protected $description = &#39;Command description&#39;;     /**      * Create a new command instance.      *      * @return void      */     public function __construct()     {         parent::__construct();     }     /**      * Execute the console command.      *      * @return mixed      */     public function handle()     {         echo $this->argument("name").PHP_EOL; ????????echo?123; ????} }

$signature為是否接收參數,?表示非必須。 arguement接收參數

執行

?php?artisan?laravel:test ? ?php?artisan?laravel:test?xiaoming

【相關推薦:laravel

以上就是聊聊?

? 版權聲明
THE END
喜歡就支持一下吧
點贊13 分享