PHPackages                             ericychu/forsun-laravel - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. ericychu/forsun-laravel

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

ericychu/forsun-laravel
=======================

高性能定时服务

v1.0.6(7y ago)014MITPHPPHP &gt;=7.1

Since Mar 9Pushed 7y ago1 watchersCompare

[ Source](https://github.com/EricYChu/forsun-laravel)[ Packagist](https://packagist.org/packages/ericychu/forsun-laravel)[ RSS](/packages/ericychu-forsun-laravel/feed)WikiDiscussions master Synced yesterday

READMEChangelog (1)Dependencies (3)Versions (8)Used By (0)

forsun-laravel
==============

[](#forsun-laravel)

使用高性能的定时调度服务 forsun 的 Laravel/Lumen 组件。

主要特性
----

[](#主要特性)

- 轻松支持千万级定时任务调度。
- 定时任务触发推送到 Queue，轻松支持跨机器和共性能分布式。
- 支持任务到期触发 command、Job、Shell、Http 和 Event。
- 支持驱动原生 Laravel Schedule 运行。
- 支持创建延时任务和定时到期任务，和原生 Laravel Schedule 保持相同接口，轻松使用。

安装
--

[](#安装)

- 安装启动 forsun 服务，详情请看 [forsun](https://github.com/snower/forsun)。
- composer 安装 forsun-laravel。

```
composer require ericychu/forsun-laravel

```

配置
--

[](#配置)

### Laravel

[](#laravel)

- 在 config/app.php 注册 ServiceProvider 和 Facade

```
'providers' => [
    // ...
    Snower\LaravelForsun\ServiceProvider::class,
],
'aliases' => [
    // ...
    'Forsun' => Snower\LaravelForsun\Facade::class,
],

```

- 创建配置文件

```
php artisan vendor:publish --provider="Snower\LaravelForsun\ServiceProvider"

```

- 修改应用根目录下的 config/forsun.php 中对应的参数即可。

### Lumen

[](#lumen)

- 在 bootstrap/app.php 注册 Service Provider 和 Facade

```
// 注册 Service Provider
$app->register(Snower\LaravelForsun\ServiceProvider::class);

// 注册 Facade
$app->withFacades(true, [
    ...,
    Snower\LaravelForsun\Facade::class => 'Forsun',
]);

```

- 拷贝配置文件

```
cp /PROJECT_DIRECTORY/vendor/ericychu/forsun-laravel/src/config.php /PROJECT_DIRECTORY/config/forsun.php

```

- 修改应用根目录下的 config/forsun.php 中对应的参数即可。

使用
--

[](#使用)

### 定义调度

[](#定义调度)

- Artisan 命令调度。

```

//不指定 name 时自动生成
Forsun::plan()->command('emails:send --force')->daily();

//指定 name
Forsun::plan('email')->command(EmailsCommand::class, ['--force'])->daily();

```

- 队列任务调度

```
Forsun::plan()->job(new Heartbeat)->everyFiveMinutes();

```

- Shell 命令调度

```
Forsun::plan()->exec('node /home/forge/script.js')->daily();

```

- Event 事件调度

```
Forsun::plan()->fire('testevent', [])->everyMinute();

```

- HTTP 事件调度

```
Forsun::plan()->http('https://www.google.com')->everyMinute();

```

注意：

- 每个任务只能设置一次调度频率。
- 不支持任务输出、任务钩子及维护模式。
- Forsun::plan 是不指定任务名时自动生成，每个任务名必须唯一，相同任务名重复定义将会自动覆盖。

### 移除调度

[](#移除调度)

```
$plan = Forsun::plan()->command('emails:send --force')->daily();
$plan->remove();

$plan = Forsun::plan()->command('emails:send --force')->daily();
$plan_name = $plan->getName();
Forsun::remove($plan_name);

```

### 调度频率设置

[](#调度频率设置)

方法描述-&gt;hourly();每小时运行-&gt;hourlyAt(17);每小时的第 17 分钟执行一次任务-&gt;daily();每天午夜执行一次任务-&gt;dailyAt('13:00');每天的 13:00 执行一次任务-&gt;monthly();每月执行一次任务-&gt;monthlyOn(4, '15:00');在每个月的第四天的 15:00 执行一次任务-&gt;everyMinute();每分钟执行一次任务-&gt;everyFiveMinutes();每五分钟执行一次任务-&gt;everyTenMinutes();每十分钟执行一次任务-&gt;everyFifteenMinutes();每十五分钟执行一次任务-&gt;everyThirtyMinutes();每半小时执行一次任务-&gt;at(strtoetime("2018-03-05 12:32:12"));在指定时间2018-03-05 12:32:12运行一次-&gt;interval(10);从当前时间开始计算每10秒运行一次-&gt;later(5);从当前时间开始计算稍后5秒运行一次-&gt;delay(30);从当前时间开始计算稍后30秒运行一次需要复杂定时控制建议生成多个定时任务或是在处理器中再次发起定时任务计划更简便同时也性能更高。

调度器应该尽可能使用Event或是Job通过Queue Work可以更高性能运行。

### 驱动原生Laravel Schedule运行

[](#驱动原生laravel-schedule运行)

```
#注册
php artisan forsun:schedule:register

#取消注册
php artisan forsun:schedule:unregister

```

开发者
---

[](#开发者)

- [snower](mailto:sujian199@gmail.com) ([twitter](http://twitter.com/snower199))

开源许可协议
------

[](#开源许可协议)

The code for Predis is distributed under the terms of the MIT license (see [LICENSE](LICENSE)).

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 80% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~38 days

Recently: every ~32 days

Total

7

Last Release

2756d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/6fc06d3a44afebb588f3eba3f7f2515527e1796fa061cda5aa95ece1e072510c?d=identicon)[EricYZhu](/maintainers/EricYZhu)

---

Top Contributors

[![snower](https://avatars.githubusercontent.com/u/2220463?v=4)](https://github.com/snower "snower (20 commits)")[![ericyzhu](https://avatars.githubusercontent.com/u/1786762?v=4)](https://github.com/ericyzhu "ericyzhu (5 commits)")

---

Tags

laravelsdkforsun

### Embed Badge

![Health badge](/badges/ericychu-forsun-laravel/health.svg)

```
[![Health](https://phpackages.com/badges/ericychu-forsun-laravel/health.svg)](https://phpackages.com/packages/ericychu-forsun-laravel)
```

###  Alternatives

[firefly-iii/data-importer

Firefly III Data Import Tool.

7545.8k](/packages/firefly-iii-data-importer)[scottybo/laravel-facebook-sdk

Fully unit tested Facebook SDK v5 integration for Laravel 7.x

2225.0k](/packages/scottybo-laravel-facebook-sdk)[willywes/agora-sdk-php

Agora.io SDK PHP

1023.2k2](/packages/willywes-agora-sdk-php)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
