aurimasniekis/scheduler-bundle
Composer 安装命令:
composer require aurimasniekis/scheduler-bundle
包简介
A simple Symfony Job Scheduling Bundle
关键字:
README 文档
README
A simple scheduler bundle for Symfony which provides a way to execute code at specific cron expressions without modifying cron tab every time.
Install
Via Composer
$ composer require aurimasniekis/scheduler-bundle
Add line to bundle.php:
<?php return [ Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true], // ... AurimasNiekis\SchedulerBundle\AurimasNiekisSchedulerBundle::class => ['all' => true], ];
Add the scheduler to cron tab to run every minute:
* * * * * /path/to/symfony/install/bin/console scheduler:run 1>> /dev/null 2>&1
Usage
Scheduler Bundle uses Symfony Container autoconfigure feature which automatically registers all services
which implement ScheduledJobInterface or NamedScheduledJobInterface interface into Scheduler.
To create a scheduled job you have two options either simple Scheduled Job or Named Scheduled Job. First one uses class name as job name, second provides method to define a job name.
<?php use AurimasNiekis\SchedulerBundle\ScheduledJobInterface; class NamelessJob implements ScheduledJobInterface { public function __invoke(): void { // Execute some logic } public function getSchedulerExpresion(): string { return '*/5 * * * *'; // Run every 5 minutes } }
<?php use AurimasNiekis\SchedulerBundle\NamedScheduledJobInterface; class NamedJob implements NamedScheduledJobInterface { public function __invoke(): void { // Execute some logic } public function getName(): string { return 'named_job'; } public function getSchedulerExpresion(): string { return '*/5 * * * *'; // Run every 5 minutes } }
Console Commands
scheduler:list
List all registered scheduled jobs, and their next scheduled run times
$ bin/console scheduler:list +------------------------------+-------------+---------- Scheduled Jobs -------------------------------------------------------+ | Name | Expression | Next Scheduled Run Times | +------------------------------+-------------+---------------------------------------------------------------------------------+ | named_job | */5 * * * * | 2020-03-22T04:55:00+00:00, 2020-03-22T05:00:00+00:00, 2020-03-22T05:05:00+00:00 | | App\ScheduledJob\NamelessJob | */5 * * * * | 2020-03-22T04:55:00+00:00, 2020-03-22T05:00:00+00:00, 2020-03-22T05:05:00+00:00 | +------------------------------+-------------+---------------------------------------------------------------------------------+
scheduler:execute
Executes a scheduled job manually
$ bin/console scheduler:execute named_job
Executing Scheduled Job: "named_job"
scheduler:run
Command to run all scheduled jobs at this moment. (Used for cron job definition)
* * * * * /path/to/symfony/install/bin/console scheduler:run 1>> /dev/null 2>&1
Testing
Run test cases
$ composer test
Run test cases with coverage (HTML format)
$ composer test-coverage
Run PHP style checker
$ composer cs-check
Run PHP style fixer
$ composer cs-fix
Contributing
Please see CONTRIBUTING and CONDUCT for details.
License
Please see License File for more information.
aurimasniekis/scheduler-bundle 适用场景与选型建议
aurimasniekis/scheduler-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 7 次下载、GitHub Stars 达 1, 最近一次更新时间为 2020 年 03 月 22 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「symfony」 「cron」 「job」 「cronjob」 「scheduler」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 aurimasniekis/scheduler-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 aurimasniekis/scheduler-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 aurimasniekis/scheduler-bundle 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Symfony bundle to monitor and execute commands
The bundle for easy using json-rpc api on your project
Provides a possibility to auto-setup crontabs required for project based on configuration file.
SlimQ Enables You to push jobs to background workers
PHP client for Kue priority job queue API
Scheduling extension for Yii2 framework
统计信息
- 总下载量: 7
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 13
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-03-22