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

Abandoned → [innmind/io](/?search=innmind%2Fio)ArchivedLibrary[Utility &amp; Helpers](/categories/utility)

innmind/stream
==============

Wrapper to PHP stream functions

4.2.0(2y ago)0109.6k↓41%[1 issues](https://github.com/Innmind/Stream/issues)4MITPHPPHP ~8.2

Since Jul 22Pushed 2y ago1 watchersCompare

[ Source](https://github.com/Innmind/Stream)[ Packagist](https://packagist.org/packages/innmind/stream)[ Docs](http://github.com/Innmind/Stream)[ RSS](/packages/innmind-stream/feed)WikiDiscussions develop Synced 1mo ago

READMEChangelog (7)Dependencies (10)Versions (27)Used By (4)

Stream
======

[](#stream)

[![Build Status](https://github.com/Innmind/Stream/workflows/CI/badge.svg?branch=master)](https://github.com/Innmind/Stream/actions?query=workflow%3ACI)[![codecov](https://camo.githubusercontent.com/3387c9e20fba06cdb47e7facbf2830fdfeb9d67c7e2c4bb45e602b48bdae4494/68747470733a2f2f636f6465636f762e696f2f67682f496e6e6d696e642f53747265616d2f6272616e63682f646576656c6f702f67726170682f62616467652e737667)](https://codecov.io/gh/Innmind/Stream)[![Type Coverage](https://camo.githubusercontent.com/6771aa4f17d662a22c2af4031acaa76909ae840afd5cb1a223d71b5ddf1050c7/68747470733a2f2f73686570686572642e6465762f6769746875622f496e6e6d696e642f53747265616d2f636f7665726167652e737667)](https://shepherd.dev/github/Innmind/Stream)

Simple wrapper to work with resource streams.

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

[](#installation)

```
composer require innmind/stream
```

Usage
-----

[](#usage)

File handling:

```
use Innmind\Stream\Streams;
use Innmind\Url\Path;

$file = Streams::of()->readable()->open(Path::of('/some/path/to/a/file'));

while (!$file->end()) {
    echo $file->readLine()->match(
        static fn($line) => $line->toString(),
        static fn() => throw new \Exception('failed to read the stream'),
    );
}

$file->close()->match(
    static fn() => null, // closed correctly
    static fn() => throw new \Exception('failed to close the stream'),
);
```

Socket handling:

```
use Innmind\Stream\{
    Stream\Bidirectional,
    Streams,
};
use Innmind\TimeContinuum\Earth\ElapsedPeriod;
use Innmind\Immutable\Either;

$socket = Bidirectional::of(\stream_socket_client('unix:///path/to/socket.sock'));
$select = Streams::of()
    ->watch()
    ->timeoutAfter(new ElapsedPeriod(60 * 1000)) // select with a 1 minute timeout
    ->forRead($socket);

do {
    $socket = $select()
        ->filter(static fn($ready) => $ready->toRead()->contains($socket))
        ->flatMap(static fn() => $socket->read())
        ->map(static fn($data) => $data->toUpper())
        ->match(
            static fn($data) => $socket->write($data),
            static fn() => Either::right($socket), // no data to send
        )
        ->match(
            static fn($socket) => $socket, // data sent back
            static fn($error) => throw new \Exception(\get_class($error)),
        );
} while (true);
```

This example will listen for messages sent from the socket `unix:///path/to/socket.sock` and will send it back in upper case.

###  Health Score

42

—

FairBetter than 90% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity31

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity86

Battle-tested with a long release history

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

Recently: every ~136 days

Total

25

Last Release

975d ago

Major Versions

1.5.0 → 2.0.02019-12-13

2.3.0 → 3.0.02022-01-29

3.3.0 → 4.0.02023-01-29

PHP version history (6 changes)1.0.0PHP ~7.1

1.5.0PHP ~7.2

2.0.0PHP ~7.4

2.2.0PHP ~7.4|~8.0

3.0.0PHP ~8.1

4.1.0PHP ~8.2

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/851425?v=4)[Baptiste Langlade](/maintainers/Baptouuuu)[@Baptouuuu](https://github.com/Baptouuuu)

---

Top Contributors

[![Baptouuuu](https://avatars.githubusercontent.com/u/851425?v=4)](https://github.com/Baptouuuu "Baptouuuu (149 commits)")

---

Tags

stream

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[react/stream

Event-driven readable and writable streams for non-blocking I/O in ReactPHP

689126.8M194](/packages/react-stream)[trafficcophp/bytebuffer

Node.js inspired byte stream buffer for PHP.

33437.2k17](/packages/trafficcophp-bytebuffer)[markrogoyski/itertools-php

Iteration tools for PHP

14911.3k](/packages/markrogoyski-itertools-php)[alexandre-daubois/lazy-stream

Write data to streams, only when it is really needed to.

755.7k](/packages/alexandre-daubois-lazy-stream)[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)
