sivaschenko/utility-cron
Composer 安装命令:
composer create-project sivaschenko/utility-cron
包简介
Cron PHP library
README 文档
README
The PHP Cron Library can be used to get human readable cron expression description and detailed validation messages. Any level of expression complexity is handled.
Code examples
Human readable cron expression description example:
$expression = \Sivaschenko\Utility\Cron\ExpressionFactory::getExpression('5 4 8 * *');
echo $expression->getVerbalString(); // "At 04:05, on 8th day of month."
Cron expression validation example:
$expression = \Sivaschenko\Utility\Cron\ExpressionFactory::getExpression('60 * * * 2- *');
if (!$expression->isValid()) {
print_r($expression->getValidationMessages());
}
/*
Array
(
[0] => Minute expression part value "60" is greater than max allowed "59"
[1] => Missing second part of "range" expression ("2-")
)
*/
Functionality examples
Examples of expression translation to verbal format:
| Cron Expression | Description |
|---|---|
| * * * * * | At every minute. |
| @weekly | On Monday at midnight |
| 5 4 8 * * | At 04:05, on 8th day of month. |
| * * * * FRIL * | At every minute, on last Friday of the month. |
| * * * 2/2 mon/3 | At every minute, every 2nd month starting from February, every 3rd day of week starting from Monday. |
| 30/5 2-6 ? jan,feb 2#4 2017 | Every 5th minute starting from 30th, every hour from 2nd through 6th, in January and February, every 4th Tuesday, in 2017 |
Examples of cron expression validation:
| Invalid Cron Expression | Validation Messages |
|---|---|
| fd * * * * * | Minute expression part value "fd" is not valid! Allowed values are integers from 0 to 59, keywords: "*", "?" |
| 60 * * * 2# * | Minute expression part value "60" is greater than max allowed "59", Missing second part of "each" expression ("2#") |
| * * * * mon/tue * | Second part of expression "mon/tue" can only be integer! |
| * * 4L * * * | Day of month expression part value "4L" is not valid! Allowed values are integers from 1 to 31, keywords: "*", "?", "W", "L" Allowed suffixes: "W" |
| @invalid | Unknown shortcut expression "@invalid"! List of valid shortcut expressions: "@reboot", "@midnight", "@daily", "@yearly", "@annually", "@monthly", "@weekly", "@hourly". |
Installation
Add dependency on library to composer.json and update or execute the following command:
composer require sivaschenko/utility-cron
Be sure to require composer generated autoload in your project:
require 'vendor/autoload.php';
Now see "Code examples" for usage instructions.
Test Coverage
Verbal translation, validation and even exceptions are covered with integration tests.
See \Sivaschenko\Utility\Cron\Test\ExpressionTest for details.
Crafted with ♥ for developers.
sivaschenko/utility-cron 适用场景与选型建议
sivaschenko/utility-cron 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 123.71k 次下载、GitHub Stars 达 7, 最近一次更新时间为 2016 年 11 月 20 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 sivaschenko/utility-cron 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 sivaschenko/utility-cron 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 123.71k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 7
- 点击次数: 12
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-11-20