tourze / workerman-runtime-context-bundle
Workerman Runtime Context bundle
0.0.3
2025-04-25 03:39 UTC
Requires
- php: ^8.1
- symfony/config: ^6.4
- symfony/dependency-injection: ^6.4
- symfony/framework-bundle: ^6.4
- symfony/http-kernel: ^6.4
- symfony/yaml: ^6.4 || ^7.1
- tourze/symfony-runtime-context-bundle: 0.0.*
- workerman/coroutine: ^1.1
- workerman/workerman: ^5.1
Requires (Dev)
- maglnet/composer-require-checker: ^4
- phpstan/phpstan: ^2.1
- phpunit/phpunit: ^10.0
This package is auto-updated.
Last update: 2025-05-14 08:50:55 UTC
README
A Symfony bundle that enables efficient coroutine context management for Workerman v5 event loop, providing context isolation and coroutine-friendly service integration with minimal code changes.
Features
- Seamless integration of Workerman coroutine context into Symfony applications
- Automatic context isolation for each coroutine (Fiber, Swoole, Swow)
- Support for context-aware connection pools and resource management
- Compatible with Symfony 6.4+
- Minimal or zero code modification needed in your existing Symfony app
Installation
- PHP >= 8.1
- Symfony 6.4 or higher
- Workerman >= 5.1
Install via Composer:
composer require tourze/workerman-runtime-context-bundle
Quick Start
- Enable the bundle in your Symfony application (usually auto-registered via Flex):
// config/bundles.php return [ // ... Tourze\WorkermanRuntimeContextBundle\WorkermanRuntimeContextBundle::class => ['all' => true], ];
- Use context-aware services in your code. For example, to defer a callback in coroutine:
use Tourze\Symfony\RuntimeContextBundle\Service\ContextServiceInterface; public function someMethod(ContextServiceInterface $contextService) { $contextService->defer(function () { // This will be executed at the end of the coroutine }); }
- See examples/ for advanced coroutine and context isolation usage, including Fiber, connection pool, and concurrency model tests.
Documentation
- Coroutine Context Isolation: How context is isolated between coroutines
- Connection Pool Usage: Resource sharing and reuse
- Concurrency Model Comparison: Serial, Parallel, Barrier, Channel models
Advanced Configuration
This bundle automatically decorates the default ContextServiceInterface
to provide Workerman coroutine support. No manual configuration is required for most use cases.
Contributing
- Please submit issues and pull requests via GitHub
- Follow PSR coding standards and Symfony best practices
- Run tests via PHPUnit before submitting PRs
License
MIT License. See LICENSE for details.
Authors
tourze https://github.com/tourze
Changelog
See Releases for version history and upgrade notes.