tourze/workerman-runtime-context-bundle

Workerman Runtime Context bundle

0.0.3 2025-04-25 03:39 UTC

This package is auto-updated.

Last update: 2025-05-14 08:50:55 UTC


README

English | 中文

Latest Version Build Status Quality Score Total Downloads

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

  1. Enable the bundle in your Symfony application (usually auto-registered via Flex):
// config/bundles.php
return [
    // ...
    Tourze\WorkermanRuntimeContextBundle\WorkermanRuntimeContextBundle::class => ['all' => true],
];
  1. 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
    });
}
  1. See examples/ for advanced coroutine and context isolation usage, including Fiber, connection pool, and concurrency model tests.

Documentation

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.