PHPackages                             tourze/quic-streams - 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. [API Development](/categories/api)
4. /
5. tourze/quic-streams

ActiveLibrary[API Development](/categories/api)

tourze/quic-streams
===================

QUIC Protocol Streams Management Implementation

0.0.1(11mo ago)00MITPHPPHP ^8.1CI failing

Since Jun 3Pushed 6mo agoCompare

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

READMEChangelog (1)Dependencies (5)Versions (2)Used By (0)

QUIC Streams Package
====================

[](#quic-streams-package)

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

[![Latest Version](https://camo.githubusercontent.com/3a6c5f8ae4b94afe6bd7090cbacd00cdffbdc2c03f000ead92876370739be3fb/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f746f75727a652f717569632d73747265616d732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/tourze/quic-streams)[![License](https://camo.githubusercontent.com/c591299cb63e53cb941456ed0ffb378610981ebad3c8885426d3a0d0942d300a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f746f75727a652f717569632d73747265616d732e7376673f7374796c653d666c61742d737175617265)](https://github.com/tourze/quic-streams/blob/main/LICENSE)[![Build Status](https://camo.githubusercontent.com/92c5dd25a23a896cdbcdc5d2ec51bd9f860db4ade43c916d6f48c24f2d2bbf39/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f746f75727a652f717569632d73747265616d732f706870756e69742e796d6c3f7374796c653d666c61742d737175617265)](https://github.com/tourze/quic-streams/actions)[![Code Coverage](https://camo.githubusercontent.com/4c390883f1041f266049a735e2367d13d1b8eb49798323f23a2fc071dd1e090f/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f6769746875622f746f75727a652f717569632d73747265616d732e7376673f7374796c653d666c61742d737175617265)](https://codecov.io/gh/tourze/quic-streams)[![Quality Score](https://camo.githubusercontent.com/2d14e7dbce412c7942aa97df1fd5dbe17ed62e897104e7cd74db50851cf47700/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f746f75727a652f717569632d73747265616d732e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/tourze/quic-streams)[![Total Downloads](https://camo.githubusercontent.com/3278fd3bd7feeab38280aac1d4ffa2f6123f5c442d420f9b18d61b9c3f939d54/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f746f75727a652f717569632d73747265616d732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/tourze/quic-streams)

QUIC协议流管理实现包，提供完整的QUIC流生命周期管理功能。

Features
--------

[](#features)

- ✅ Bidirectional and unidirectional stream support
- ✅ Stream state machine management
- ✅ Data buffering and ordering
- ✅ Flow control integration
- ✅ Exception error handling
- ✅ Memory-optimized buffer management

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

[](#installation)

```
composer require tourze/quic-streams
```

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

[](#requirements)

- PHP 8.1 or higher
- tourze/quic-core
- tourze/quic-flow-control
- tourze/quic-frames

Quick Start
-----------

[](#quick-start)

### 创建流管理器

[](#创建流管理器)

```
use Tourze\QUIC\Streams\StreamManager;
use Tourze\QUIC\FlowControl\FlowControlManager;

// 创建流控制管理器（可选）
$flowControlManager = new FlowControlManager();

// 创建流管理器
$streamManager = new StreamManager(
    isServer: true,
    flowControlManager: $flowControlManager
);
```

### 创建流

[](#创建流)

```
use Tourze\QUIC\Core\Enum\StreamType;

// 创建双向流
$bidirectionalStream = $streamManager->createStream(StreamType::CLIENT_BIDI);

// 创建单向流
$unidirectionalStream = $streamManager->createStream(StreamType::CLIENT_UNI);
```

### 发送和接收数据

[](#发送和接收数据)

```
// 发送数据
$stream->send('Hello QUIC!', fin: false);
$stream->send('Final message', fin: true);

// 接收数据
$stream->receive('Received data', offset: 0, fin: false);
```

### 流状态管理

[](#流状态管理)

```
use Tourze\QUIC\Streams\StreamStateMachine;

$stateMachine = new StreamStateMachine();

// 状态转换
$success = $stateMachine->transitionSend(StreamSendState::SEND);

// 检查状态
if ($stateMachine->canSend()) {
    // 可以发送数据
}

if ($stateMachine->isClosed()) {
    // 流已关闭
}
```

### 缓冲区管理

[](#缓冲区管理)

```
use Tourze\QUIC\Streams\StreamBuffer;

// 创建缓冲区（默认1MB）
$buffer = new StreamBuffer();

// 添加发送数据
$offset = $buffer->addSendData('Data to send');

// 获取发送数据
$sendData = $buffer->getSendData(maxLength: 1200);

// 添加接收数据
$buffer->addRecvData('Received data', offset: 0);

// 获取连续的接收数据
$recvData = $buffer->getRecvData();
```

API Reference
-------------

[](#api-reference)

### 核心类

[](#核心类)

- `Stream` - 抽象流基类
- `BidirectionalStream` - 双向流实现
- `UnidirectionalStream` - 单向流实现
- `StreamManager` - 流管理器
- `StreamBuffer` - 数据缓冲区
- `StreamStateMachine` - 流状态机
- `StreamException` - 流异常

### 流类型

[](#流类型)

根据RFC 9000规范：

- `StreamType::CLIENT_BIDI` (0) - 客户端发起的双向流
- `StreamType::SERVER_BIDI` (1) - 服务器发起的双向流
- `StreamType::CLIENT_UNI` (2) - 客户端发起的单向流
- `StreamType::SERVER_UNI` (3) - 服务器发起的单向流

Error Handling
--------------

[](#error-handling)

```
use Tourze\QUIC\Streams\StreamException;
use Tourze\QUIC\Core\Enum\QuicError;

try {
    $stream->send('data');
} catch (StreamException $e) {
    $quicError = $e->getQuicError();
    echo "QUIC Error: " . $quicError->name;
}
```

Testing
-------

[](#testing)

```
# 运行单元测试
./vendor/bin/phpunit packages/quic-streams/tests

# 运行静态分析
./vendor/bin/phpstan analyse packages/quic-streams/src --level=max
```

Dependencies
------------

[](#dependencies)

- `tourze/quic-core` - QUIC核心定义
- `tourze/quic-frames` - QUIC帧处理
- `tourze/quic-flow-control` - 流量控制

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING.md](../../CONTRIBUTING.md) for details.

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE) for more information.

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance65

Regular maintenance activity

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity35

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

340d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/e354fdb316da535dfa8ba2e9193a473c403b6bc6fb9170778d1dc50e304c6e9d?d=identicon)[tourze](/maintainers/tourze)

---

Top Contributors

[![tourze](https://avatars.githubusercontent.com/u/13899502?v=4)](https://github.com/tourze "tourze (3 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/tourze-quic-streams/health.svg)

```
[![Health](https://phpackages.com/badges/tourze-quic-streams/health.svg)](https://phpackages.com/packages/tourze-quic-streams)
```

###  Alternatives

[stripe/stripe-php

Stripe PHP Library

4.0k143.3M475](/packages/stripe-stripe-php)[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M270](/packages/twilio-sdk)[knplabs/github-api

GitHub API v3 client

2.2k15.8M187](/packages/knplabs-github-api)[facebook/php-business-sdk

PHP SDK for Facebook Business

90121.9M34](/packages/facebook-php-business-sdk)[microsoft/microsoft-graph

The Microsoft Graph SDK for PHP

65723.5M95](/packages/microsoft-microsoft-graph)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

73813.7M114](/packages/meilisearch-meilisearch-php)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
