componenta/stream-iterator 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

componenta/stream-iterator

Composer 安装命令:

composer require componenta/stream-iterator

包简介

Stream iterator for line-based resource traversal

README 文档

README

Iterator for reading PSR-7 streams in fixed-size chunks.

Use it for uploads, downloads, hashing, conversion, and other streaming workflows where loading the full body into memory is unnecessary.

Installation

composer require componenta/stream-iterator

Requires psr/http-message.

Related Packages

Package Why it matters here
psr/http-message StreamIterator reads PSR-7 StreamInterface.
psr/http-message Uploads, downloads, and request bodies can expose PSR-7 streams.
componenta/iterator Use it when replayable iteration is needed; stream iteration keeps only the current chunk.
componenta/image-converter Upload streams can be read before media processing.

Usage

use Componenta\Stdlib\StreamIterator;

$iterator = new StreamIterator($stream, bytesPerIteration: 1024);

foreach ($iterator as $offset => $chunk) {
    // $offset is the stream position where the chunk started.
}

Contract

StreamIterator implements Iterator and Stringable.

Important behavior:

  • current() is idempotent
  • reading happens during rewind() and next()
  • repeated calls to current() do not consume more bytes
  • key() returns the chunk start offset
  • withStream() and withBytes() return cloned iterators
  • setBytes() mutates bytes-per-iteration on the current instance

Memory Model

The iterator keeps only the current chunk. It does not cache previous chunks and does not make a one-shot stream replayable. Use componenta/iterator if you need replayable iteration.

统计信息

  • 总下载量: 0
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-06-14

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固