Laravel Scheduling Package
Laravel 是在 App\Console\Kernel 類(lèi)中的 schedule 方法去定義所有的調(diào)度任務(wù)。
iBrand 產(chǎn)品作為一個(gè)電商類(lèi)產(chǎn)品,本身業(yè)務(wù)需求非常龐大和復(fù)雜,全部定義在 schedule 方法中會(huì)非常臃腫。而且 iBrand 產(chǎn)品的每個(gè)模塊都是一個(gè) Package,具有高度的復(fù)用性。
所以我們開(kāi)發(fā)了此包,用來(lái)把各個(gè)模塊的調(diào)度任務(wù)放在自己的包里,而不是全部放在 App\Console\Kernel 類(lèi)的 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(); } 復(fù)制代碼}
register
Add follow line to you ServiceProvider register method.
$this->app->make(iBrand\Scheduling\ScheduleList::class)->add(YourSchedule::class); 歡迎大家 star 和提交 issue :) Laravel & VUE & 小程序 & 電商產(chǎn)品 交流群:674454674 暗號(hào):segmentfault
總結(jié)
以上是生活随笔為你收集整理的Laravel Scheduling Package的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 转赋值表达式解析的流程
- 下一篇: SAP Business One on