tourze/symfony-runtime-context-bundle

Symfony ไธŠไธ‹ๆ–‡็ฎก็†ๅ’Œๅปถ่ฟŸๆ‰ง่กŒๆจกๅ—

Maintainers

๐Ÿ‘ tourze

Package info

github.com/tourze/symfony-runtime-context-bundle

Type:symfony-bundle

pkg:composer/tourze/symfony-runtime-context-bundle

Statistics

Installs: 18โ€‰110

Dependents: 8

Suggesters: 0

Stars: 0

Open Issues: 0

1.0.1 2025-11-01 19:26 UTC

MIT ec3f72cd616c4bb80a72d8c9746fe25d2dbd764c

This package is auto-updated.

Last update: 2026-06-19 10:31:35 UTC


README

English | ไธญๆ–‡

๐Ÿ‘ Latest Version
๐Ÿ‘ Total Downloads
๐Ÿ‘ PHP Version Require
๐Ÿ‘ License
๐Ÿ‘ Coverage Status

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

  1. Register the bundle in config/bundles.php:

    return [
     Tourze\Symfony\RuntimeContextBundle\RuntimeContextBundle::class => ['all' => true],
    ];
  2. 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 support
  • DefaultContextService: Default implementation based on process ID or generated unique ID
  • DeferCallSubscriber: 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