PHPackages                             tourze/symfony-aop-coroutine-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. tourze/symfony-aop-coroutine-bundle

ActiveSymfony-bundle[Utility &amp; Helpers](/categories/utility)

tourze/symfony-aop-coroutine-bundle
===================================

Symfony AOP 协程支持，为服务实例提供协程隔离和上下文管理

1.0.2(5mo ago)023MITPHPCI passing

Since Apr 17Pushed 4mo ago1 watchersCompare

[ Source](https://github.com/tourze/symfony-aop-coroutine-bundle)[ Packagist](https://packagist.org/packages/tourze/symfony-aop-coroutine-bundle)[ RSS](/packages/tourze-symfony-aop-coroutine-bundle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (8)Dependencies (19)Versions (9)Used By (0)

Symfony AOP Coroutine Bundle
============================

[](#symfony-aop-coroutine-bundle)

[English](README.md) | [中文](README.zh-CN.md)

[![Latest Version](https://camo.githubusercontent.com/0ab317b7f19ccdcb98e70967c84e8817b52ad1c63fbafb4677fcb8066d18ad53/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f746f75727a652f73796d666f6e792d616f702d636f726f7574696e652d62756e646c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/tourze/symfony-aop-coroutine-bundle)[![Build Status](https://camo.githubusercontent.com/87a5b416c8ae8dc1812ededaaddbc16746cd06dc2e93f1b01d1d006d6b848bc1/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f746f75727a652f73796d666f6e792d616f702d636f726f7574696e652d62756e646c652f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/tourze/symfony-aop-coroutine-bundle)[![Quality Score](https://camo.githubusercontent.com/19531e6895eb9fd5d466b012ee03b9437b6e1e3560c5cfe1b684af0ad9744915/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f746f75727a652f73796d666f6e792d616f702d636f726f7574696e652d62756e646c652e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/tourze/symfony-aop-coroutine-bundle)[![Coverage Status](https://camo.githubusercontent.com/36af745f841d35ddf4d0536387cec502f1a9d6b67644abe51d27ba05d51fc5b0/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f746f75727a652f73796d666f6e792d616f702d636f726f7574696e652d62756e646c652e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/tourze/symfony-aop-coroutine-bundle/?branch=master)[![Total Downloads](https://camo.githubusercontent.com/2e545b8a3a71328181433dba8d5e91ce730a6a407af9892d4f6563f495276c9f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f746f75727a652f73796d666f6e792d616f702d636f726f7574696e652d62756e646c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/tourze/symfony-aop-coroutine-bundle)[![PHP Version Require](https://camo.githubusercontent.com/bea5c351a8ca2d6fa64e45d78e7a02fef3ab01ebb19fd4c87d5133ba724718c6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f746f75727a652f73796d666f6e792d616f702d636f726f7574696e652d62756e646c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/tourze/symfony-aop-coroutine-bundle)[![License](https://camo.githubusercontent.com/50bbff41ace8575f20a135767eba4deb89de02d6f7e5a7c517bc828229b3e89a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f746f75727a652f73796d666f6e792d616f702d636f726f7574696e652d62756e646c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/tourze/symfony-aop-coroutine-bundle)

A Symfony bundle that provides coroutine-based service isolation using AOP (Aspect-Oriented Programming), enabling each request context to have its own independent service instances for better state isolation and concurrent processing.

Table of Contents
-----------------

[](#table-of-contents)

- [Features](#features)
- [Requirements](#requirements)
- [Installation](#installation)
- [Quick Start](#quick-start)
    - [Basic Usage](#basic-usage)
- [Built-in Coroutine Services](#built-in-coroutine-services)
    - [Request &amp; Routing Services](#request-routing-services)
    - [Template Engine](#template-engine)
    - [Security Services](#security-services)
    - [Logging Services](#logging-services)
    - [Other Services](#other-services)
- [Advanced Configuration](#advanced-configuration)
    - [Alternative Ways to Enable Coroutine](#alternative-ways-to-enable-coroutine)
    - [Enhanced Logging](#enhanced-logging)
- [Important Notes](#important-notes)
- [How It Works](#how-it-works)
- [Testing](#testing)
- [Contributing](#contributing)
    - [Development Setup](#development-setup)
- [License](#license)
- [Changelog](#changelog)

Features
--------

[](#features)

- **AOP-based service isolation**: Uses Aspect-Oriented Programming to intercept service calls and provide isolated instances
- **Simple annotation-based configuration**: Mark services as coroutine-enabled with the `#[AsCoroutine]` attribute
- **Built-in support for common services**: Automatic coroutine support for request\_stack, twig, monolog, Doctrine EntityManager, session handlers, and more
- **Automatic context management**: Handles context creation and cleanup for each request lifecycle
- **Enhanced logging**: Automatically adds coroutine context ID to all log records for better traceability
- **Memory efficient**: Only creates isolated instances when needed, with automatic cleanup

Requirements
------------

[](#requirements)

- PHP 8.1 or higher
- Symfony 6.4 or higher
- `tourze/symfony-aop-bundle` for AOP functionality
- `tourze/symfony-runtime-context-bundle` for context management

Installation
------------

[](#installation)

Install via Composer:

```
composer require tourze/symfony-aop-coroutine-bundle

```

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

```
