PHPackages                             zenstruck/stream - 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. zenstruck/stream

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

zenstruck/stream
================

Object wrapper for PHP resources.

v1.3.0(5mo ago)734.3k—3.9%11MITPHPPHP &gt;=8.1CI passing

Since Nov 5Pushed 3mo ago2 watchersCompare

[ Source](https://github.com/zenstruck/stream)[ Packagist](https://packagist.org/packages/zenstruck/stream)[ Docs](https://github.com/zenstruck/stream)[ GitHub Sponsors](https://github.com/kbond)[ GitHub Sponsors](https://github.com/nikophil)[ RSS](/packages/zenstruck-stream/feed)WikiDiscussions 1.x Synced 1mo ago

READMEChangelog (4)Dependencies (4)Versions (5)Used By (1)

zenstruck/stream
================

[](#zenstruckstream)

[![CI Status](https://github.com/zenstruck/stream/workflows/CI/badge.svg)](https://github.com/zenstruck/stream/actions?query=workflow%3ACI)[![codecov](https://camo.githubusercontent.com/e7c5e7ac3036d2dcc758705879846583dd47e6ed95992113e2fa0a4441d5403e/68747470733a2f2f636f6465636f762e696f2f67682f7a656e73747275636b2f73747265616d2f6272616e63682f312e782f67726170682f62616467652e7376673f746f6b656e3d334a4f31554a50485345)](https://codecov.io/gh/zenstruck/stream)

Object wrapper for PHP resources.

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

[](#installation)

```
composer require zenstruck/stream
```

API
---

[](#api)

### Create Stream Object

[](#create-stream-object)

```
use Zenstruck\Stream;

// wrap
$stream = Stream::wrap($resource);
$stream = Stream::wrap('string');
$stream = Stream::wrap($stream);

// open
$stream = Stream::open('some/file.txt', 'r');

// php://memory
$stream = Stream::inMemory();

// php://output
$stream = Stream::inOutput();

// \tmpfile()
$stream = Stream::tempFile();

// autoclose on $stream __destruct
$stream->autoClose(); // Stream
```

### Use Stream Object

[](#use-stream-object)

```
/** @var \Zenstruck\Stream $stream */

// metadata
$stream->id(); // int - the resource id
$stream->type(); // string - the resource type
$stream->metadata(); // array - the resources metadata
$stream->metadata('wrapper_type'); // mixed - specific resource metadata key
$stream->uri(); // string - shortcut for `$stream->metadata('uri')`

// read
$stream->get(); // resource - the raw, wrapped resource
$stream->contents(); // string - the contents of the resource (auto-rewound)

// write
$stream->write($resource); // self - write another resource to the stream
$stream->write('string'); // self - write a string to the stream
$stream->write($anotherStream); // self - write another \Zenstruck\Stream instance to the stream

// manipulate
$stream->close(); // no-return - close the resource (if open)
$stream->rewind(); // self - rewind the stream
```

###  Health Score

49

—

FairBetter than 95% of packages

Maintenance78

Regular maintenance activity

Popularity35

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 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

Every ~299 days

Total

5

Last Release

92d ago

PHP version history (2 changes)v1.0.0PHP &gt;=8.0

v1.3.0PHP &gt;=8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/707369cc916e0ea1aacbf077dcba464f611cef879f024d8944311a54a15224b3?d=identicon)[kbond](/maintainers/kbond)

---

Top Contributors

[![kbond](https://avatars.githubusercontent.com/u/127811?v=4)](https://github.com/kbond "kbond (21 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/zenstruck-stream/health.svg)

```
[![Health](https://phpackages.com/badges/zenstruck-stream/health.svg)](https://phpackages.com/packages/zenstruck-stream)
```

PHPackages © 2026

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