akki-io/cron-expression-generator 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

akki-io/cron-expression-generator

Composer 安装命令:

composer require akki-io/cron-expression-generator

包简介

Create a cron expression based on user input

README 文档

README

Hero

Cron Expression Generator

Latest Version Build Status Quality Score Software License StyleCI Total Downloads

Generate cron expressions based on user inputs.

Installation

You can install the package via composer:

composer require akki-io/cron-expression-generator

Introduction

A CRON expression is a string representing the schedule for a particular command to execute. The parts of a CRON schedule are as follows:

*    *    *    *    *
-    -    -    -    -
|    |    |    |    |
|    |    |    |    |
|    |    |    |    +----- day of week (0 - 6) (Sunday=0)
|    |    |    +---------- month (1 - 12)
|    |    +--------------- day of month (1 - 31)
|    +-------------------- hour (0 - 23)
+------------------------- min (0 - 59)
Cron Schedule Package Request Mapping
min minute
hour hour
day of month day_month
month month
day of week day_week

This package supports the following different options for each schedule.

Option Type (*required) Description Nested Required Parameters
ONCE Generate cron once int at, b/t the range of schedule
EVERY Generate cron for every int every, b/t the range of schedule
LIST Generate cron based on the list of values array list and int list.*, b/t the range of schedule
RANGE Generate cron based on range int start and int end both b/t the range of schedule
STEP Generate cron based on step int every, int start and int end all b/t the range of schedule

Usage

You can set the $options array below based on the different options as outlined above.

    use AkkiIo\CronExpressionGenerator\CronExpressionGenerator;

    $options = [];

    $cronExpression = (new CronExpressionGenerator($options))->generate();

Examples

Generate cron expression for every minute

    $options = [];

    $cronExpression = (new CronExpressionGenerator($options))->generate();
      
    // * * * * *

Generate cron expression for once every hour

    $options = [
        'minute' => [
            'type' => 'ONCE',
            'at' => 0,
        ],
        'hour' => [
            'type' => 'EVERY',
            'every' => 1,
        ],
    ];

    $cronExpression = (new CronExpressionGenerator($options))->generate();
    
    // 0 */1 * * *

Generate cron expression for once every day at 10:15 AM

    $options = [
        'minute' => [
            'type' => 'ONCE',
            'at' => 15,
        ],
        'hour' => [
            'type' => 'ONCE',
            'at' => 10,
        ],
    ];

    $cronExpression = (new CronExpressionGenerator($options))->generate();
    
    // 15 10 * * *

Generate cron expression for once every weekday at 10:15 AM

    $options = [
        'minute' => [
            'type' => 'ONCE',
            'at' => 15,
        ],
        'hour' => [
            'type' => 'ONCE',
            'at' => 10,
        ],
        'day_week' => [
            'type' => 'RANGE',
            'start' => 1,
            'end' => 5,
        ],
    ];

    $cronExpression = (new CronExpressionGenerator($options))->generate();
    
    // 15 10 * * 1-5

Generate cron expression for once every month of day 22 at 10:15 AM

    $options = [
        'minute' => [
            'type' => 'ONCE',
            'at' => 15,
        ],
        'hour' => [
            'type' => 'ONCE',
            'at' => 10,
        ],
        'day_month' => [
            'type' => 'ONCE',
            'at' => 22,
        ],
    ];

    $cronExpression = (new CronExpressionGenerator($options))->generate();
      
    // 15 10 22 * *

Generate cron expression for every Sunday at 10:15 AM

    $options = [
        'minute' => [
            'type' => 'ONCE',
            'at' => 15,
        ],
        'hour' => [
            'type' => 'ONCE',
            'at' => 10,
        ],
        'day_week' => [
            'type' => 'ONCE',
            'at' => 0,
        ],
    ];

    $cronExpression = (new CronExpressionGenerator($options))->generate();
      
    // 15 10 * * 0

Generate cron expression for every year on Oct 22 at 10:15 AM

    $options = [
        'minute' => [
            'type' => 'ONCE',
            'at' => 15
        ],
        'hour' => [
            'type' => 'ONCE',
            'at' => 10,
        ],
        'day_month' => [
            'type' => 'ONCE',
            'at' => 22,
        ],
        'month' => [
            'type' => 'ONCE',
            'at' => 10,
        ],
    ];

    $cronExpression = (new CronExpressionGenerator($options))->generate();
      
    // 15 10 22 10 *

Testing

composer test

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email hello@akki.io instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-05-26

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固