下面由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 = 'laravel:test {name?}'; /** * The console command description. * * @var string */ protected $description = 'Command description'; /** * 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
喜歡就支持一下吧
相關推薦