PHPackages                             clue/reactphp-flux - 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. [Queues &amp; Workers](/categories/queues)
4. /
5. clue/reactphp-flux

ActiveLibrary[Queues &amp; Workers](/categories/queues)

clue/reactphp-flux
==================

Flux, the lightweight stream processor to concurrently do many (but not too many) things at once, built on top of ReactPHP.

v1.4.0(3y ago)59118.6k↓14.4%8[4 issues](https://github.com/clue/reactphp-flux/issues)1MITPHPPHP &gt;=5.3

Since May 25Pushed 2y ago6 watchersCompare

[ Source](https://github.com/clue/reactphp-flux)[ Packagist](https://packagist.org/packages/clue/reactphp-flux)[ Docs](https://github.com/clue/reactphp-flux)[ Fund](https://clue.engineering/support)[ GitHub Sponsors](https://github.com/clue)[ RSS](/packages/clue-reactphp-flux/feed)WikiDiscussions 1.x Synced 1mo ago

READMEChangelog (5)Dependencies (5)Versions (6)Used By (1)

clue/reactphp-flux
==================

[](#cluereactphp-flux)

[![CI status](https://github.com/clue/reactphp-flux/actions/workflows/ci.yml/badge.svg)](https://github.com/clue/reactphp-flux/actions)[![code coverage](https://camo.githubusercontent.com/2d45ae33b28ed0c5f14fdba645e579072cf437770a215524795c9eb258581b1c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f636f6465253230636f7665726167652d3130302532352d73756363657373)](#tests)[![installs on Packagist](https://camo.githubusercontent.com/421bbd82e825e7f7f5631a4a4972656d8427e1ef22783fd1fba48a1afee61765/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f636c75652f72656163747068702d666c75783f636f6c6f723d626c7565266c6162656c3d696e7374616c6c732532306f6e2532305061636b6167697374)](https://packagist.org/packages/clue/reactphp-flux)

Flux, the lightweight stream processor to concurrently do many (but not too many) things at once, built on top of [ReactPHP](https://reactphp.org/).

Let's say you have a large list of users or products that you want to process by individually sending a (RESTful) HTTP API request to some third party API for each record. Estimating each call to take around `0.3s` means that having `10000` users processed sequentially, you would have to wait around 50 minutes for all jobs to complete. This works perfectly fine for a small number of operations, but keeping thousands of jobs in memory at once may easily take up all resources on your side. Instead, you can use this library to stream your arbitrarily large input list as individual records to a non-blocking (async) transformation handler. It uses [ReactPHP](https://reactphp.org/) to enable you to concurrently process multiple records at once. You can control the concurrency limit, so that by allowing it to process 10 operations at the same time, you can thus process this large input list around 10 times faster and at the same time you're no longer limited how many records this list may contain (think processing millions of records). This library provides a simple API that is easy to use in order to manage any kind of async operation without having to mess with most of the low-level details. You can use this to throttle multiple HTTP requests, database queries or pretty much any API that already uses Promises.

- **Async execution of operations** - Choose how many async operations should be processed at once (concurrently). Process their results as soon as responses come in. The Promise-based design provides a *sane* interface to working with out of order results.
- **Standard interfaces** - Allows easy integration with existing higher-level components by implementing ReactPHP's standard [promises](#promises) and [streaming interfaces](#streaming).
- **Lightweight, SOLID design** - Provides a thin abstraction that is [*just good enough*](https://en.wikipedia.org/wiki/Principle_of_good_enough)and does not get in your way. Builds on top of well-tested components and well-established concepts instead of reinventing the wheel.
- **Good test coverage** - Comes with an [automated tests suite](#tests) and is regularly tested in the *real world*.

**Table of contents**

- [Support us](#support-us)
- [Quickstart example](#quickstart-example)
- [Usage](#usage)
    - [Transformer](#transformer)
        - [Promises](#promises)
        - [Timeout](#timeout)
        - [Streaming](#streaming)
        - [all()](#all)
        - [any()](#any)
- [Install](#install)
- [Tests](#tests)
- [License](#license)
- [More](#more)

Support us
----------

[](#support-us)

We invest a lot of time developing, maintaining and updating our awesome open-source projects. You can help us sustain this high-quality of our work by [becoming a sponsor on GitHub](https://github.com/sponsors/clue). Sponsors get numerous benefits in return, see our [sponsoring page](https://github.com/sponsors/clue)for details.

Let's take these projects to the next level together! 🚀

Quickstart example
------------------

[](#quickstart-example)

Once [installed](#install), you can use the following code to process an example user lists by sending a (RESTful) HTTP API request for each user record:

```
