tourze/symfony-runtime-context-bundle
最新稳定版本:1.0.1
Composer 安装命令:
composer require tourze/symfony-runtime-context-bundle
包简介
Symfony 上下文管理和延迟执行模块
README 文档
README
Context management module for Symfony applications, supporting deferred task execution and unique context identification.
Features
- Obtain a unique ID for the current runtime context
- Support for deferred (defer) task execution
- Reset mechanism compatible with Symfony lifecycle
- Extensible for different contexts (e.g., FPM, CLI)
Installation
- Requires PHP 8.1+
- Requires Symfony 6.4+ core components
- Install via Composer:
composer require tourze/symfony-runtime-context-bundle
Quick Start
-
Register the bundle in
config/bundles.php:return [ Tourze\Symfony\RuntimeContextBundle\RuntimeContextBundle::class => ['all' => true], ];
-
Inject and use
ContextServiceInterface:use Tourze\Symfony\RuntimeContextBundle\Service\ContextServiceInterface; public function index(ContextServiceInterface $contextService) { $id = $contextService->getId(); $contextService->defer(function () { // Deferred task }); }
Documentation
ContextServiceInterface: Defines the core context service interface, including unique ID retrieval, deferred execution, and coroutine supportDefaultContextService: Default implementation based on process ID or generated unique IDDeferCallSubscriber: Event subscriber responsible for executing all deferred tasks at the end of the lifecycle
Contributing
- Issues and PRs are welcome
- Follow PSR-12 code style
- Please ensure PHPUnit tests pass before submitting
License
- MIT License
- (c) tourze
Changelog
- See CHANGELOG.md or commit history for details
统计信息
- 总下载量: 17.61k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 7
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-04-17