PHPackages                             reactivex/rxphp - 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. reactivex/rxphp

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

reactivex/rxphp
===============

Reactive extensions for php.

2.1.0(7mo ago)1.7k3.3M↓19.7%142[7 issues](https://github.com/ReactiveX/RxPHP/issues)[8 PRs](https://github.com/ReactiveX/RxPHP/pulls)20MITPHPPHP &gt;=7.1.0CI failing

Since Jun 25Pushed 2mo ago91 watchersCompare

[ Source](https://github.com/ReactiveX/RxPHP)[ Packagist](https://packagist.org/packages/reactivex/rxphp)[ Docs](https://github.com/ReactiveX/RxPHP)[ RSS](/packages/reactivex-rxphp/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (10)Dependencies (5)Versions (34)Used By (20)

RxPHP
=====

[](#rxphp)

Reactive extensions for PHP. The reactive extensions for PHP are a set of libraries to compose asynchronous and event-based programs using observable streams.

[![CI status](https://github.com/ReactiveX/RxPHP/workflows/CI/badge.svg)](https://github.com/ReactiveX/RxPHP/actions)[![Coverage Status](https://camo.githubusercontent.com/b58608b0da211999420377b8185782bdca51d958796f1f90f31d8ab7e99c39a9/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f5265616374697665582f52785048502f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/ReactiveX/RxPHP?branch=master)

Example
-------

[](#example)

```
$source = \Rx\Observable::fromArray([1, 2, 3, 4]);

$source->subscribe(
    function ($x) {
        echo 'Next: ', $x, PHP_EOL;
    },
    function (Exception $ex) {
        echo 'Error: ', $ex->getMessage(), PHP_EOL;
    },
    function () {
        echo 'Completed', PHP_EOL;
    }
);

//Next: 1
//Next: 2
//Next: 3
//Next: 4
//Completed
```

Try out the demos
-----------------

[](#try-out-the-demos)

```
$ git clone https://github.com/ReactiveX/RxPHP.git
$ cd RxPHP
$ composer install
$ php demo/interval/interval.php
```

Have fun running the demos in `/demo`.

note: When running the demos, the scheduler is automatically bootstrapped. When using RxPHP within your own project, you'll need to set the default scheduler.

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

[](#installation)

1. Install an event loop. Any event loop should work, but the ReactPHP event loop is recommended.

```
$ composer require react/event-loop
```

2. Install RxPHP using [composer](https://getcomposer.org).

```
$ composer require reactivex/rxphp
```

3. Write some code.

```
