tobento/app-schedule
Composer 安装命令:
composer require tobento/app-schedule
包简介
App schedule support.
README 文档
README
Schedule support for the app using the Schedule Service.
Table of Contents
Getting Started
Add the latest version of the app schedule project running this command.
composer require tobento/app-schedule
Requirements
- PHP 8.4 or greater
Documentation
App
Check out the App Skeleton if you are using the skeleton.
You may also check out the App to learn more about the app in general.
Schedule Boot
The schedule boot does the following:
- implements schedule interfaces
- boots the Console Boot and adds schedule commands to console
use Tobento\App\AppFactory; use Tobento\Service\Schedule\ScheduleInterface; use Tobento\Service\Schedule\ScheduleProcessorInterface; use Tobento\Service\Schedule\TaskProcessorInterface; // Create the app $app = new AppFactory()->createApp(); // Add directories: $app->dirs() ->dir(realpath(__DIR__.'/../'), 'root') ->dir(realpath(__DIR__.'/../app/'), 'app') ->dir($app->dir('app').'config', 'config', group: 'config') ->dir($app->dir('root').'public', 'public') ->dir($app->dir('root').'vendor', 'vendor'); // Adding boots $app->boot(\Tobento\App\Schedule\Boot\Schedule::class); $app->booting(); // Implemented interfaces: $schedule = $app->get(ScheduleInterface::class); $scheduleProcessor = $app->get(ScheduleProcessorInterface::class); $taskProcessor = $app->get(TaskProcessorInterface::class); // Run the app $app->run();
If you are not using the App Skeleton check out the App Console Boot section as you might adjust the app file.
Scheduling Tasks
You can schedule tasks in severval ways:
Using the app
You may use the app on method to schedule tasks only if the schedule is requested.
use Tobento\App\AppFactory; use Tobento\Service\Schedule\ScheduleInterface; // Create the app $app = new AppFactory()->createApp(); // Add directories: $app->dirs() ->dir(realpath(__DIR__.'/../'), 'root') ->dir(realpath(__DIR__.'/../app/'), 'app') ->dir($app->dir('app').'config', 'config', group: 'config') ->dir($app->dir('root').'public', 'public') ->dir($app->dir('root').'vendor', 'vendor'); // Adding boots: $app->boot(\Tobento\App\Schedule\Boot\Schedule::class); // Adding tasks: $app->on(ScheduleInterface::class, static function(ScheduleInterface $schedule): void { $schedule->task($task); }); // Run the app $app->run();
Using a boot
You may create a boot for scheduling tasks:
use Tobento\App\Boot; use Tobento\App\Schedule\Boot\Schedule; use Tobento\Service\Schedule\ScheduleInterface; class MyScheduleTasksBoot extends Boot { public const BOOT = [ // you may ensure the schedule boot. Schedule::class, ]; public function boot() { $this->app->on(ScheduleInterface::class, static function(ScheduleInterface $schedule): void { $schedule->task($task); }); } }
Check out the Schedule Service - Schedule section to learn more about it.
Furthermore, all the Tasks and Task Parameters are ready to use without any requirements.
Running Scheduled Tasks
To run the scheduled tasks, add a cron configuration entry to your server that runs the schedule:run command every minute.
* * * * * cd /path-to-your-project && php ap schedule:run >> /dev/null 2>&1
Credits
tobento/app-schedule 适用场景与选型建议
tobento/app-schedule 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 19 次下载、GitHub Stars 达 0, 最近一次更新时间为 2023 年 12 月 01 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「package」 「schedule」 「task」 「app」 「tobento」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 tobento/app-schedule 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 tobento/app-schedule 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 tobento/app-schedule 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Enables the creation of cron-jobs tasks to be consumed by symfony/messenger
Expose the DDev executable commands to the Robo task runner.
A Deployment/Change Log Schedule and Notes system for SilverStripe sites
Monitoring for scheduled jobs
Task system for APPUI
统计信息
- 总下载量: 19
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 20
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-12-01