PHPackages                             pfinalclub/asyncio - 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. [Queues &amp; Workers](/categories/queues)
4. /
5. pfinalclub/asyncio

ActiveLibrary[Queues &amp; Workers](/categories/queues)

pfinalclub/asyncio
==================

An embeddable, composable, and reasonable PHP Async Runtime

3.0.1(4mo ago)167444MITPHPPHP &gt;=8.1

Since Oct 14Pushed 4mo ago1 watchersCompare

[ Source](https://github.com/pfinalclub/pfinal-asyncio)[ Packagist](https://packagist.org/packages/pfinalclub/asyncio)[ RSS](/packages/pfinalclub-asyncio/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (2)Versions (8)Used By (4)

PHP AsyncIO v3.0.1
==================

[](#php-asyncio-v301)

**[English](README.md)** | **[中文文档](README_CN.md)**

🚀 **An Embeddable, Composable, and Reasonable PHP Async Runtime**

> **v3.0.1 Release**: Code cleanup and optimization! Removed redundant files and improved code consistency.

[![PHP Version](https://camo.githubusercontent.com/7663c9d53dc13cedaf0660a8745a7e77d2dd711257f36aa86ebce12a0600ef42/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344382e312d626c75652e737667)](https://www.php.net/)[![License](https://camo.githubusercontent.com/8bb50fd2278f18fc326bf71f6e88ca8f884f72f179d3e555e20ed30157190d0d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d677265656e2e737667)](LICENSE)[![Workerman](https://camo.githubusercontent.com/39189db579cfaebe3368898fc6cb81fee8c9da06a39b53fcc40a0775ed95eeee/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f776f726b65726d616e2d253345253344342e312d6f72616e67652e737667)](https://github.com/walkor/workerman)

🎯 Core Philosophy
-----------------

[](#-core-philosophy)

**"A minimal, embeddable, composable, and reasonable PHP Async Runtime"**

- 🔹 **Embeddable**: Lightweight, zero-intrusion, easy to integrate
- 🔹 **Composable**: Clear component boundaries, interface-driven design
- 🔹 **Reasonable**: Predictable behavior, state-managed execution
- 🔹 **Focused**: **Only solves async runtime problems, nothing else**

✨ Features
----------

[](#-features)

### 🚀 Core Async Runtime

[](#-core-async-runtime)

- 🧵 **Native PHP Fiber** - Built on PHP 8.1+ Fibers for exceptional performance
- ⚡ **Event-Driven** - Zero polling, leveraging Workerman's high-performance event loop
- 🎯 **Structured Concurrency** - CancellationScope, TaskGroup, and gather strategies
- 📊 **Task State Management** - Type-safe state machine with TaskState enum
- 🛡️ **Exception Handling** - Complete error propagation with GatherException
- ⏰ **Precise Timing** - &lt; 0.1ms latency, timer-driven events
- 🧠 **Context Management** - Coroutine-local context variables (like Python contextvars)

### 📦 Architecture

[](#-architecture)

```
src/
├── Core/              # 🎯 Core abstractions (frozen API)
│   ├── EventLoopInterface.php  # Stable event loop interface
│   ├── EventLoop.php          # High-performance implementation
│   ├── Task.php              # Fiber-based tasks with state machine
│   └── TaskState.php         # Type-safe task states
├── Concurrency/       # 🔗 Structured concurrency
│   ├── CancellationScope.php # Scoped task cancellation
│   ├── TaskGroup.php         # Task group management
│   └── GatherStrategy.php    # Multiple gathering strategies
├── Resource/          # 🌿 Runtime resource management
│   ├── AsyncResource.php     # Resource interface
│   ├── AsyncResourceManager.php # Automatic cleanup
│   └── Context.php           # Coroutine context system
├── Observable/        # 👁️ Lightweight observability (disabled by default)
│   ├── Observable.php       # Simple event system
│   ├── Observer.php          # Observer interface
│   └── Events/TaskEvent.php  # Task lifecycle events
└── functions.php      # 🎉 Minimal API (263 lines, 13 functions)

```

🚀 Quick Start
-------------

[](#-quick-start)

### Hello AsyncIO

[](#hello-asyncio)

```
