PHPackages                             snower/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. snower/forsun-laravel

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

snower/forsun-laravel
=====================

高性能定时服务

v1.0.5(7y ago)992.7k11MITPHP

Since Mar 9Pushed 7y ago4 watchersCompare

[ Source](https://github.com/snower/forsun-laravel)[ Packagist](https://packagist.org/packages/snower/forsun-laravel)[ RSS](/packages/snower-forsun-laravel/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (6)Dependencies (2)Versions (9)Used By (0)

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

[](#forsun-laravel)

[![Software license](https://camo.githubusercontent.com/0480f887f4a5198d8224d203dc0149b3ecf0b901b3493f5db092bb999d2b9eb8/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f736e6f7765722f666f7273756e2d6c61726176656c2e7376673f7374796c653d666c61742d737175617265)](LICENSE)[![Latest stable](https://camo.githubusercontent.com/12488bb33ffb3e419ca0eb974c5cffd2f13bc43306f8b107aa50b35ef0403382/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f736e6f7765722f666f7273756e2d6c61726176656c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/snower/forsun-laravel)[![Latest development](https://camo.githubusercontent.com/7d95e839f72be3eafe1f3750f447c0908f85fc0e8e56de64a1a8353524616010/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f767072652f736e6f7765722f666f7273756e2d6c61726176656c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/snower/forsun-laravel)[![Monthly installs](https://camo.githubusercontent.com/64279ff4e4b4b52d509b765d27ab6c31fd928545d369e99bcced58262b08f062/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646d2f736e6f7765722f666f7273756e2d6c61726176656c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/snower/forsun-laravel/stats)

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

Main features
-------------

[](#main-features)

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

Install
-------

[](#install)

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

```
composer require "snower/forsun-laravel"

```

Config
------

[](#config)

- 在 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 中对应的参数即可。

Used
----

[](#used)

### 定义调度

[](#定义调度)

- 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('http://www.baidu.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

```

Author
------

[](#author)

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

License
-------

[](#license)

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

###  Health Score

37

—

LowBetter than 81% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity33

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity68

Established project with proven stability

 Bus Factor1

Top contributor holds 100% 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 ~63 days

Recently: every ~84 days

Total

8

Last Release

2591d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/2220463?v=4)[snower](/maintainers/snower)[@snower](https://github.com/snower)

---

Top Contributors

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

---

Tags

forsunlaravellaravel-frameworkschedulelaravelsdkforsun

### Embed Badge

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

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

###  Alternatives

[scottybo/laravel-facebook-sdk

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

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

Agora.io SDK PHP

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

PHPackages © 2026

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