PHPackages                             kusabi/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. [PSR &amp; Standards](/categories/psr-standards)
4. /
5. kusabi/stream

ActiveLibrary[PSR &amp; Standards](/categories/psr-standards)

kusabi/stream
=============

A PSR-7 and PSR-17 conforming stream wrapper library for PHP

1.0.7(5y ago)011MITPHPPHP ^7.0

Since Jul 12Pushed 5y agoCompare

[ Source](https://github.com/kusabi/stream)[ Packagist](https://packagist.org/packages/kusabi/stream)[ RSS](/packages/kusabi-stream/feed)WikiDiscussions main Synced 3d ago

READMEChangelog (1)Dependencies (6)Versions (9)Used By (0)

Stream wrapper
==============

[](#stream-wrapper)

[![Tests](https://github.com/kusabi/stream/workflows/tests/badge.svg)](https://github.com/kusabi/stream/workflows/tests/badge.svg)[![codecov](https://camo.githubusercontent.com/2e21f1a2da582d6ec74e4ac0c232bf1667cd9e28fbd9d61fd95caa2f75b68036/68747470733a2f2f636f6465636f762e696f2f67682f6b75736162692f73747265616d2f6272616e63682f6d61696e2f67726170682f62616467652e737667)](https://codecov.io/gh/kusabi/stream)[![Licence Badge](https://camo.githubusercontent.com/1325470e736627d7aa0df3f317f33b53d7c226488507a44b83bb5e3dea1078fc/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6b75736162692f73747265616d2e737667)](https://img.shields.io/github/license/kusabi/stream.svg)[![Release Badge](https://camo.githubusercontent.com/a1ab9443559b4749df3e92d40fb13c8f3838c314777cb74cf8284661a17105a9/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f6b75736162692f73747265616d2e737667)](https://img.shields.io/github/release/kusabi/stream.svg)[![Tag Badge](https://camo.githubusercontent.com/f1e523bdba5fd0d638524e033c0e0a5b532c18465a3cecc1c19b8a3d85086d7d/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f7461672f6b75736162692f73747265616d2e737667)](https://img.shields.io/github/tag/kusabi/stream.svg)[![Issues Badge](https://camo.githubusercontent.com/dc75f7c6889da7d0e908064efb94d057acb645b339d945322069435f3daa7391/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f6b75736162692f73747265616d2e737667)](https://img.shields.io/github/issues/kusabi/stream.svg)[![Code Size](https://camo.githubusercontent.com/48738f7dfc991d75ac6ee3cc8fca0b7032619ea5b3c740f8165ab4bffc357e26/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c616e6775616765732f636f64652d73697a652f6b75736162692f73747265616d2e7376673f6c6162656c3d73697a65)](https://img.shields.io/github/languages/code-size/kusabi/stream.svg)

An implementation of a [PSR-7](https://www.php-fig.org/psr/psr-7/) &amp; [PSR-17](https://www.php-fig.org/psr/psr-17/) conforming Stream library

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

[](#installation)

Installation is simple using composer.

```
composer require kusabi/stream
```

Or simply add it to your `composer.json` file

```
{
    "require": {
        "kusabi/stream": "^1.0"
    }
}
```

Using streams
-------------

[](#using-streams)

The Stream class is a very basic wrapper around a stream resource.

```
use Kusabi\Stream\Stream;

// Instantiate a Uri instance
$stream = new Stream(fopen('php://stdin', 'r'));

// Fetch the properties of the Stream
$stream->getContents(); // Get everything from the current pointer to the end of the stream
$stream->getSize(); // Get the size of the stream in bytes
$stream->isSeekable();
$stream->isReadable();
$stream->isWritable();
$stream->seek($offset, $whence = SEEK_SET); // Move the pointer around in the stream
$stream->tell(); // Where is the pointer in the stream
$stream->rewind(); // Set the pointer to the beginning of the stream
$stream->read($length); // Read the next $length character from the stream
$stream->write($string); // Write data into the stream. Returns the number of bytes written
$stream->getMetadata($key = null); // Get all the metadata, or a particular key
$stream->getStat($key = null); // Get all the fstat entries, or a particular key
$stream->isLocal(); // Determine if the stream url is local using `stream_is_local()`
$stream->getLine($length = null, $ending = "\n"); // Fetch a line up to a length or delimiter (which ever comes first)
$stream->pipe(Stream $stream); // Copy the contents of one stream into another
(string) $stream; // Rewind and get all the contents from the stream
```

Using the stream factory
------------------------

[](#using-the-stream-factory)

The Stream factory can be used to create the Stream instance too.

```
use Kusabi\Stream\StreamFactory;

// Instantiate a Uri instance
$factory = new StreamFactory();
$stream = $factory->createStream('temp resource with data in it');
$stream = $factory->createStreamFromFile('file.txt');
$stream = $factory->createStreamFromResource(fopen('php://stdin', 'r'));
```

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity59

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 ~68 days

Recently: every ~119 days

Total

8

Last Release

2023d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/62f4942978644437b5ff3d7bd3f6411580413d327b001104acd4914f43ab63b6?d=identicon)[kusabi](/maintainers/kusabi)

---

Top Contributors

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

---

Tags

phppsrpsr-17psr-7streamwrapper

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

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

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

###  Alternatives

[dragon-code/contracts

A set of contracts for any project

108.8M37](/packages/dragon-code-contracts)[phpro/http-tools

HTTP tools for developing more consistent HTTP implementations.

28137.8k](/packages/phpro-http-tools)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)

PHPackages © 2026

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