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

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

bzrk/php-stream
===============

a library to simplify handling(filter, map, ...) collections in php

2.00(1y ago)611.0k↓41.7%2MITPHPPHP &gt;= 8.2CI passing

Since Sep 23Pushed 1mo ago2 watchersCompare

[ Source](https://github.com/bzrk/php-stream)[ Packagist](https://packagist.org/packages/bzrk/php-stream)[ RSS](/packages/bzrk-php-stream/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (4)Versions (22)Used By (2)

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

[](#php-stream)

---

A library to handle Collections like in Java

Stream Class
------------

[](#stream-class)

- public **count**(): int
- public **map**(Closure $call): Stream
- public **flatMap**(Closure $call): Stream
- public **filter**(Closure $call): Stream
- public **notNull**(): Stream
- public **notEmpty**(): Stream
- public **each**(Closure $call): void
- public **toList**(bool $keepKeys = false): array
- public **toMap**(Closure $key, Closure $value): array
- public **first**(): mixed
- public **limit**(int $size): Stream
- public **order**(Comparator $comparator): Stream
- public **run**(): Stream
- public **skip**(int $count): Stream
- public **implode**(string $separator = ','): string
- public **join**(string $separator = ','): string --&gt; alias for implode
- public **batch**(int $count): Stream
- public **associateBy**(Closure $call): array
- public **collect**(string $class): Collection
- public **toGenerator**(Closure $call = null, $default = null): Generator
- public **callBack**(Closure $call): Stream

Streams Class
-------------

[](#streams-class)

- public static **of**(array|Iterator|File|CsvFile $data): Stream
- public static **range**(int $start, int $inclusiveEnd): Stream
- public static **split**(string $pattern, string $source): Stream

Examples
--------

[](#examples)

```
$data = [
    (object)["name" => "hallo", "data" => ["a", "b"]],
    (object)["name" => "hallo", "data" => ["a", "b", "H", "g"]],
    (object)["name" => "hallo", "data" => ["a", "b", "d"]],
];

$result = Streams::of($data)
    ->map(fn(object $obj) => (object)["name" => $obj->name, "cnt" => count($obj->data)])
    ->filter(fn(object $obj) => $obj->cnt !== 4)
    ->order(new Comparator(fn(object $a, object $b) => $a->cnt - $b->cnt))
    ->map(fn(object $obj) => "$obj->name - $obj->cnt")
    ->toList();
//Result is
['hallo - 2', 'hallo - 3']
```

Create a Stream from a Typed Collection

```
class User { ... }

class UserCollection extends Collection
{
    public function __construct(User ...$data)
    {
        parent::__construct($data);
    }

    public function add(User $value): void
    {
        parent::addEntry($value);
    }
}

(new UserCollection(new User("name")))->stream()->map(....)
```

more Examples in the testsuite.

Running Test
------------

[](#running-test)

```
composer verify
```

or

```
docker-compose up
```

###  Health Score

50

—

FairBetter than 96% of packages

Maintenance71

Regular maintenance activity

Popularity30

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity72

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

Recently: every ~228 days

Total

20

Last Release

421d ago

Major Versions

0.17 → 1.02024-04-02

1.01 → 2.002025-03-23

PHP version history (3 changes)0.1PHP &gt;= 8

0.10PHP &gt;= 7.4

1.0PHP &gt;= 8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/445ce1a0aac262330f9ea50db89f69de168758ca03040646429cd862e251dfb1?d=identicon)[bzrk](/maintainers/bzrk)

---

Top Contributors

[![bzrk](https://avatars.githubusercontent.com/u/2979008?v=4)](https://github.com/bzrk "bzrk (9 commits)")

---

Tags

streamarrayfiltercollectionlistmapping

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[phpcollection/phpcollection

General-Purpose Collection Library for PHP

1.0k64.0M34](/packages/phpcollection-phpcollection)[cuyz/valinor

Dependency free PHP library that helps to map any input into a strongly-typed structure.

1.5k9.2M108](/packages/cuyz-valinor)[aimeos/map

Easy and elegant handling of PHP arrays as array-like collection objects similar to jQuery and Laravel Collections

4.2k412.9k11](/packages/aimeos-map)[athari/yalinqo

YaLinqo, a LINQ-to-objects library for PHP

4561.2M5](/packages/athari-yalinqo)[graze/sort

A collection of array sorting transforms and functions

12289.6k2](/packages/graze-sort)[graze/data-structure

Data collections and containers

12287.4k8](/packages/graze-data-structure)

PHPackages © 2026

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