fm-labs/cakephp-cron
最新稳定版本:2.2.1
Composer 安装命令:
composer require fm-labs/cakephp-cron
包简介
Cron Job plugin for CakePHP
README 文档
README
A Cronjob plugin for CakePHP
Installation
composer require fm-labs/cakephp-cron
Create a custom CronTask
namespace App\Cron class MyCronTask implements \Cron\Cron\ICronTask { public execute() { // ... do some magic ... //return new CronTaskResult(false, "Something went wrong") return new CronTaskResult(true, "Success") } }
Configuration
In your Plugin.php or bootstrap.php
\Cron\Cron::setConfig('my_cron', [ 'className' => \App\Cron\MyCronTask, 'interval' => 3600, // interval in seconds ])
Execute cron tasks
Via Http / Browser
# to run a specific task curl -v https://YOUR_BASE_URL/cron/my_cron # to run all tasks curl -v https://YOUR_BASE_URL/cron/all
Via CLI
# to run a specific task ./cake cron run my_cron # to run all tasks ./cake cron run all
Password protect cron task execution
# to run all tasks
curl -v https://USER:PASSWORD@YOUR_BASE_URL/cron/all
Under the hood
- Tasks are statically configured via
Cronclass. - The
CronControllerinstantiates theCronManager - The
CronManagerloads configured tasks fromCronclass and on invokation:- Instantiates the cron task class (implementing the
ICronTaskinterface) - Fires the
Cron.beforeTaskevent - Executes the cron task
- Fires the
Cron.afterTaskevent
- Instantiates the cron task class (implementing the
统计信息
- 总下载量: 96
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-01-04