PHPackages                             hguenot/phpstream - 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. hguenot/phpstream

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

hguenot/phpstream
=================

PHPStream claims to be a partial PHP port of the Java Stream API.

V3.0.0(5y ago)116021MITPHPPHP &gt;=8.0.0

Since Feb 19Pushed 3y ago1 watchersCompare

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

READMEChangelog (8)Dependencies (2)Versions (11)Used By (1)

PHP Stream
==========

[](#php-stream)

PHP Stream is a basic port of new [Java Stream API](http://www.oracle.com/technetwork/articles/java/ma14-java-se-8-streams-2177646.html)in PHP.

This library could be used to filter, convert or reduce any array.

Continuous integration
----------------------

[](#continuous-integration)

[![Build Status](https://camo.githubusercontent.com/e98306c0cb96ddd63b75f3425f86673a541f0163dd4407ec2d854dfa89051ac3/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f686775656e6f742f70687073747265616d)](https://travis-ci.org/github/hguenot/phpstream)[![Code coverage](https://camo.githubusercontent.com/4d27f378fcd73e2bf2d096793fc297114b726789f0831d425855f4f3efbcd8a2/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f6769746875622f686775656e6f742f70687073747265616d)](https://codecov.io/github/hguenot/phpstream/)[![GitHub last version](https://camo.githubusercontent.com/f0bdaaa635f01a56fafe033479a96ad196b665351dfe2750c7152085358415e8/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f72656c656173652f686775656e6f742f70687073747265616d)](https://github.com/hguenot/phpstream/releases)[![Packagist last version](https://camo.githubusercontent.com/f14bd2ae7b09e5ed600d2c8b3929c719b8995685c2848e7989324ffeebbaa26e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f686775656e6f742f70687073747265616d)](https://packagist.org/packages/hguenot/phpstream)[![Packagist downloads](https://camo.githubusercontent.com/35f428757e5db8ee50cda2fe336655166078895dc5accd9572598de4e3a98a9b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f686775656e6f742f70687073747265616d)](https://packagist.org/packages/hguenot/phpstream)

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

[](#installation)

The preferred way to install this extension is through [composer](http://getcomposer.org/download/).

Either run

```
php composer.phar require --prefer-dist hguenot/phpstream "*"

```

or add

```
"hguenot/phpstream": "*"

```

to the require section of your `composer.json` file.

Usage
-----

[](#usage)

- Here is a basic usage of this library.

```
// Create a simple array of data
$array = [ -10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ];

// Creates a Stream based on the previous array
$stream = new \phpstream\Stream($array);

// Compute the opposite value of each value
$stream = $stream->map(function($value){
    return intval($value) * (-1);
});

// Get only odd values
$stream = $stream->filter(function($value){
    return (intval($value) % 2) == 0;
});

// Collects data into an array
$new_array = $stream->collect(new \phpstream\collectors\ListCollector());

// Computes sum of all elements
$sum = $stream->reduce(function($a, $b){
    return intval($a) + intval($b);
}, 0);
```

- All stream operations can be chained :

```
$sum = \phpstream\Stream::of($array)
    ->map(function($value){
        return intval($value) * (-1);
    })
    ->filter(function($value){
        return (intval($value) % 2) == 0;
    })
    ->reduce(function($a, $b){
        return intval($a) + intval($b);
    }, 0);
```

You can find more examples on PHPUnit test.

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity74

Established project with proven stability

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

Recently: every ~220 days

Total

8

Last Release

1899d ago

Major Versions

v1.4.0 → v2.0.02020-05-02

V2.0.1 → V3.0.02021-03-07

PHP version history (3 changes)v1.4.0PHP ^7.1.3

v2.0.0PHP &gt;=7.1.3

V3.0.0PHP &gt;=8.0.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/6f980dc7f653be656d2725f6457567a666e792e4173ba57536de674b6f3e291e?d=identicon)[hguenot](/maintainers/hguenot)

---

Top Contributors

[![hguenot](https://avatars.githubusercontent.com/u/2578010?v=4)](https://github.com/hguenot "hguenot (29 commits)")

---

Tags

streamjava stream api

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/hguenot-phpstream/health.svg)

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

###  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)

PHPackages © 2026

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