tourze / symfony-runtime-context-bundle
上下文管理模块
Installs: 106
Dependents: 4
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:symfony-bundle
Requires
- php: ^8.1
- symfony/config: ^6.4
- symfony/console: ^6.4
- symfony/dependency-injection: ^6.4
- symfony/event-dispatcher: ^6.4
- symfony/framework-bundle: ^6.4
- symfony/http-kernel: ^6.4
- symfony/service-contracts: ^2.5 || ^3
Requires (Dev)
- phpstan/phpstan: ^2.1
This package is auto-updated.
Last update: 2025-04-20 11:42:29 UTC
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