m-adamski/symfony-schedule-bundle
Composer 安装命令:
composer require m-adamski/symfony-schedule-bundle
包简介
Schedule Bundle for Symfony
README 文档
README
Bundle for simplifying operations with CRON jobs.
Installation
This Bundle can be installed by Composer:
$ composer require m-adamski/symfony-schedule-bundle
How to use it?
Bundle provide functionality to manage CRON jobs by configuration from specified file.
We need to create class implementing Adamski\Symfony\ScheduleBundle\Model\ManagerInterface interface.
namespace App\Model;
use Adamski\Symfony\ScheduleBundle\Model\ManagerInterface;
use Adamski\Symfony\ScheduleBundle\Model\Schedule;
class ScheduleManager implements ManagerInterface {
public function schedule(Schedule $schedule) {
// TODO: ..
}
}
Then we need to complete the configuration - create file config/packages/schedule.yaml and set path to ScheduleManager:
schedule:
manager: App\Model\ScheduleManager
Command schedule configuration
In function schedule we can configure CRON jobs with required expressions.
For example we want run app:test-command daily at 12:00:
public function schedule(Schedule $schedule) {
$schedule->command("app:test-command")->dailyAt("12:00");
}
Schedule class provide many date-time manipulators. This functionality is inspired by Laravel Tasks Scheduling.
Schedule Frequency Options
There are many schedules that you can assign to your task.
| Method |
|---|
| cron($expression) |
| everyMinute() |
| everyFiveMinutes() |
| cron($expression) |
| everyMinute() |
| everyFiveMinutes() |
| everyTenMinutes() |
| everyFifteenMinutes() |
| everyThirtyMinutes() |
| hourly() |
| hourlyAt(int $offset) |
| daily() |
| at(string $time) |
| dailyAt(string $time) |
| twiceDaily(int $first = 1, int $second = 13) |
| weekdays() |
| weekends() |
| mondays() |
| tuesdays() |
| wednesdays() |
| thursdays() |
| fridays() |
| saturdays() |
| sundays() |
| weekly() |
| weeklyOn(int $day, string $time = "0:0") |
| monthly() |
| monthlyOn(int $day = 1, string $time = "0:0") |
| twiceMonthly(int $first = 1, int $second = 16) |
| quarterly() |
| yearly() |
| days($days) |
CRON
Now it's enough to insert only one entry into crontab on server:
* * * * * php /path-to-project/bin/console schedule:run >> schedule.log 2>&1
License
MIT
m-adamski/symfony-schedule-bundle 适用场景与选型建议
m-adamski/symfony-schedule-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 35.18k 次下载、GitHub Stars 达 14, 最近一次更新时间为 2018 年 07 月 12 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 m-adamski/symfony-schedule-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 m-adamski/symfony-schedule-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 35.18k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 14
- 点击次数: 15
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-07-12