Skip to content

OverNaive/think-swoole-crontab

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

think-swoole-crontab

A crontab component base on think-swoole.

声明

核心逻辑来自于 Hyperfhyperf/crontab 组件。非常感谢 Hyperf 为大家提供这么优的组件。

本组件试图让其运行在 ThinkPHP 里(需结合 think-swoole 组件)。

目前还处于初步可用阶段,后续会慢慢完善。

Requirement

Installation

composer require overnaive/think-swoole-crontab

Documents

Usage

  1. event.php 里为 swoole.init 事件添加监听类。
return [
...
    'listem' => [
        ...
        'swoole.init' => [
            ...
            \ThinkSwooleCrontab\Process\CrontabDispatcherProcess::class,
            ...
        ],
        ...
    ],
...
];
  1. 在配置文件 crontab.php 里添加 \ThinkSwooleCrontab\Crontab 实例。
return [
    'crontab' => [
        (new \ThinkSwooleCrontab\Crontab())->setName('test-1')
            ->setRule('* * * * * *')
            ->setCallback([Test::class, 'run'])
            ->setMemo('just a test crontab'),
        (new \ThinkSwooleCrontab\Crontab())->setName('test-2')
            ->setRule('* * * * * *')
            ->setCallback([Test::class, 'run'])
            ->setMemo('just another test crontab'),
    ],
];

License

MIT

About

A crontab component base on think-swoole.

Resources

License

Stars

Watchers

Forks

Languages