beauty-framework/jobs
Composer 安装命令:
composer require beauty-framework/jobs
包简介
Beauty Jobs
README 文档
README
This package provides a RoadRunner-compatible jobs system for the Beauty PHP framework, with Laravel-style fluent APIs, DI container support, and full PSR compatibility.
Installation
composer require beauty-framework/jobs
Features
- Works with RoadRunner pipelines
- Works with
memory,AMQP,Kafka, etc. - Fluent Job options API:
withDelay(),onQueue(),tags() - Uses
Opis\Closurefor serializable job payloads - Integrates with DI container (
ContainerInterface)
Requirements
- RoadRunner installed and configured
- jobs plugin configured in
.rr.yaml - PHP 8.1+
Creating a Job
To generate a job, use the built-in console command:
./beauty generate:job TestJob
This will create app/Jobs/TestJob.php with a default stub implementation.
Example job:
<?php namespace App\Jobs; use Beauty\Jobs\AbstractJob; class TestJob extends AbstractJob { public function __construct( public readonly string $message = 'Hello from job!', ) {} public function handle(): void { file_put_contents(storage_path('logs/test.log'), $this->message . PHP_EOL, FILE_APPEND); } }
Dispatching a Job
Jobs are dispatched via the Dispatcher class. You can resolve it via the container:
use App\Jobs\TestJob; use Beauty\Jobs\Dispatcher; public function someControllerMethod(Dispatcher $dispatcher) { $job = (new TestJob('123')) ->withDelay(5) ->onQueue('emails') ->tags('welcome', 'user:123'); $dispatcher->dispatch($job); }
You can also override options:
$dispatcher->dispatch($job, options: new JobOptions(timeout: 30), queue: 'critical');
Fluent API available
withDelay(int $seconds)withTimeout(int $seconds)withMaxTries(int $tries)withHeader(string $key, string $value)onQueue(string $name)tags(string ...$tags)
These options are embedded in the serialized job and automatically passed to RoadRunner.
Under the Hood
AbstractJobimplementsJobInterfaceand includes DI container awarenessJobRunnerhandles job execution- Serialized with
Opis\Closure - RoadRunner feeds the job through
pipes, and the worker picks it up viaConsumer
RoadRunner Configuration
Reference: RoadRunner Jobs Plugin Docs
Sample .rr.yaml:
server: command: "php workers/rr-worker.php" relay: pipes jobs: consume: ["default"] pool: command: "php workers/rr-worker.php" num_workers: 4 debug: true pipelines: default: driver: memory config: priority: 1 prefetch: 100 consumers: default: pipeline: default
Make sure your worker script (e.g., rr-worker.php) is capable of receiving jobs and invoking JobRunner.
License
MIT
beauty-framework/jobs 适用场景与选型建议
beauty-framework/jobs 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 14 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 06 月 10 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「jobs」 「beauty」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 beauty-framework/jobs 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 beauty-framework/jobs 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 beauty-framework/jobs 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
This module enables subscription to latest jobs by email
Super-simple, minimum abstraction Lever DATA API v1 wrapper in PHP with support for Laravel.
Schedule your tasks right from the code.
Adds Queues to Flarum
A database-backed alternative to Horizon & Laravel Queues — durable jobs, sophisticated batches, high observability & scheduling that survive worker and host crashes, with no Redis to operate.
The beauty Library.
统计信息
- 总下载量: 14
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 9
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-06-10