Laravel Scheduling Package
Laravel 是在 App\Console\Kernel 類中的 schedule 方法去定義所有的調度任務。
iBrand 產品作為一個電商類產品,本身業務需求非常龐大和復雜,全部定義在 schedule 方法中會非常臃腫。而且 iBrand 產品的每個模塊都是一個 Package,具有高度的復用性。
所以我們開發了此包,用來把各個模塊的調度任務放在自己的包里,而不是全部放在 App\Console\Kernel 類的 schedule 方法中。
github: ibrandcc/laravel-scheduling
Installation
$ composer require ibrand/laravel-scheduling -vvv
If your Laravel version below 5.5, you need add the follow line to the section providers of config/app.php:
iBrand\Scheduling\ServiceProvider::class,
Usage
extend Scheduling abstract class
use iBrand\Scheduling\Scheduling;
class YourSchedule extends Scheduling {
public function schedule(){//Your schedule logic.$this->schedule->call(function () {})->daily(); } 復制代碼}
register
Add follow line to you ServiceProvider register method.
$this->app->make(iBrand\Scheduling\ScheduleList::class)->add(YourSchedule::class); 歡迎大家 star 和提交 issue :) Laravel & VUE & 小程序 & 電商產品 交流群:674454674 暗號:segmentfault
總結
以上是生活随笔為你收集整理的Laravel Scheduling Package的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 转赋值表达式解析的流程
- 下一篇: SAP Business One on