定制 fm-labs/cakephp-cron 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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 Cron class.
  • The CronController instantiates the CronManager
  • The CronManager loads configured tasks from Cron class and on invokation:
    • Instantiates the cron task class (implementing the ICronTask interface)
    • Fires the Cron.beforeTask event
    • Executes the cron task
    • Fires the Cron.afterTask event

统计信息

  • 总下载量: 96
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-01-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固