1.建立自定義命令檔案
php artisan make:command 你的的命令檔名字 eg:php artisan make:command SendEmails
php artisan make:command 你的的命令檔名字 eg:php artisan make:command SendEmails
2.開啟Kernel檔案註冊你的命令(不要問我為什麼打碼,不想給你看)


protected $commands = [
Commands\SendEmails::class
];
3.開始構建你的程式碼
protected $signature = '你的命令名字 {--選項名字= : 幫助文件}';
eg:
protected $signature = 'sendEmails:generate {--type= : a生成商場文件;b生成Admin文件;}';
protected $description = '整體命令的介紹';
eg:
protected $description = '傳送郵件';
public function handle()
{
$message='這是你的訊息提示';
if (($this->option('type'))=='a') {
$message='傳送a事件郵件成功';
} elseif (($this->option('type'))=='b') {
$message='傳送b事件郵件成功';
}
$this->comment($message);
}
現在你就可以構建一條屬於自己的命令了。例如下面這樣子的:

本作品採用《CC 協議》,轉載必須註明作者和本文連結