PHPackages                             bertptrs/phpstreams - 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. bertptrs/phpstreams

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

bertptrs/phpstreams
===================

A streams library for PHP based on the Java 8 Streams API.

v0.1.0(9y ago)883.2k3[1 PRs](https://github.com/bertptrs/phpstreams/pulls)MITPHPPHP &gt;=5.5.9CI failing

Since Jul 18Pushed 7y ago4 watchersCompare

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

READMEChangelogDependencies (4)Versions (2)Used By (0)

PHPStreams
==========

[](#phpstreams)

[![Latest Stable Version](https://camo.githubusercontent.com/447e433b8f36d37c07366b8782bae3dd1ed1f073a7523b4d98b3bd563117d1e8/68747470733a2f2f706f7365722e707567782e6f72672f62657274707472732f70687073747265616d732f762f737461626c65)](https://packagist.org/packages/bertptrs/phpstreams) [![Total Downloads](https://camo.githubusercontent.com/36ee4518ca3a0becb433e228aaa4ca22d4fcb1adccb84d101fef6e4217090756/68747470733a2f2f706f7365722e707567782e6f72672f62657274707472732f70687073747265616d732f646f776e6c6f616473)](https://packagist.org/packages/bertptrs/phpstreams) [![License](https://camo.githubusercontent.com/a641edbd9877886a7d0fa04b8deb962c9373604ee21510b6c005441ef3eee036/68747470733a2f2f706f7365722e707567782e6f72672f62657274707472732f70687073747265616d732f6c6963656e7365)](https://packagist.org/packages/bertptrs/phpstreams) [![Build Status](https://camo.githubusercontent.com/8d87c2bcd459685949cf496bfc6b44b98cf2bd875280644d5359e8939e3bf704/68747470733a2f2f7472617669732d63692e6f72672f62657274707472732f70687073747265616d732e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/bertptrs/phpstreams)

A partial implementation of the Java 8 Streams API in PHP. PHPStreams can use your generators, your arrays and really anything that is [Iterable](https://wiki.php.net/rfc/iterable) and convert modify it like you're used to using Java Streams!

Using streams and generators, you can easily sort through large amounts of data without having to have it all in memory or in scope. Streams also make it easier to structure your code, by (more or less) enforcing single resposibility.

The library is compatible with PHP 5.5.9 and up.

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

[](#installation)

PHPStreams can be installed using Composer. Just run `composer require bertptrs/phpstreams` in your project root!

Usage
-----

[](#usage)

Using streams is easy. Say, we want the first 7 odd numbers in the Fibonacci sequence. To do this using Streams, we do the following:

```
// Define a generator for Fibonacci numbers
function fibonacci()
{
    yield 0;
    yield 1;

    $prev = 0;
    $cur = 1;

    while (true) {
        yield ($new = $cur + $prev);
        $prev = $cur;
        $cur = $new;
    }
};

// Define a predicate that checks for odd numbers
$isOdd = function($num) {
    return $num % 2 == 1;
};

// Create our stream.
$stream = new phpstreams\Stream(fibonacci());

// Finally, use these to create our result.
$oddFibo = $stream->filter($isOdd)  // Keep only the odd numbers
    ->limit(8)                      // Limit our results
    ->toArray(false);               // Convert to array, discarding keys
```

Documentation
-------------

[](#documentation)

Documentation is mostly done using PHPDoc. I do intend to write actual documtation if there is any interest.

Contributing
------------

[](#contributing)

I welcome contributions and pull requests. Please note that I do follow PSR-2 (and PSR-4 for autoloading). Also, please submit unit tests with your work.

GrumPHP enforces at least part of the coding standard, but do make an effort to structure your contributions nicely.

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity34

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity48

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

Unknown

Total

1

Last Release

3591d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/e86239cab6d01f69aae6c6569b0af03bf7c6ef4ed75d06b77aa2643775135202?d=identicon)[bertptrs](/maintainers/bertptrs)

---

Top Contributors

[![bertptrs](https://avatars.githubusercontent.com/u/861864?v=4)](https://github.com/bertptrs "bertptrs (23 commits)")

---

Tags

java-streamsphpstream

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/bertptrs-phpstreams/health.svg)

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

###  Alternatives

[thiagomarini/binocular

Doing Event Sourcing without building a spaceship

373.0k](/packages/thiagomarini-binocular)[adigital/gdprdatachecker

Run through the database and pull out any information associated with a specified email address

151.0k](/packages/adigital-gdprdatachecker)

PHPackages © 2026

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