PHPackages                             werkint/reactphp-event-loop - 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. werkint/reactphp-event-loop

Abandoned → [werkint/reactphp-event-loop](/?search=werkint%2Freactphp-event-loop)Library[Utility &amp; Helpers](/categories/utility)

werkint/reactphp-event-loop
===========================

Event loop abstraction layer that libraries can use for evented I/O.

v0.4.2(10y ago)01.4kMITPHPPHP &gt;=5.4.0

Since Jul 11Pushed 9y ago4 watchersCompare

[ Source](https://github.com/Werkint/reactphp-event-loop)[ Packagist](https://packagist.org/packages/werkint/reactphp-event-loop)[ RSS](/packages/werkint-reactphp-event-loop/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependenciesVersions (16)Used By (0)

EventLoop Component
===================

[](#eventloop-component)

[![Build Status](https://camo.githubusercontent.com/ea2d212926716932067920b35e16ec79cb2adfa35d0e95191038f427333d646d/68747470733a2f2f7365637572652e7472617669732d63692e6f72672f72656163747068702f6576656e742d6c6f6f702e706e673f6272616e63683d6d6173746572)](http://travis-ci.org/reactphp/event-loop) [![Code Climate](https://camo.githubusercontent.com/9fdb77cbe4624e98a9bfd86dea358194cee41c15f29dfaba6f1b0312009087ca/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f72656163747068702f6576656e742d6c6f6f702f6261646765732f6770612e737667)](https://codeclimate.com/github/reactphp/event-loop)

Event loop abstraction layer that libraries can use for evented I/O.

In order for async based libraries to be interoperable, they need to use the same event loop. This component provides a common `LoopInterface` that any library can target. This allows them to be used in the same loop, with one single `run` call that is controlled by the user.

In addition to the interface there are some implementations provided:

- `StreamSelectLoop`: This is the only implementation which works out of the box with PHP. It does a simple `select` system call. It's not the most performant of loops, but still does the job quite well.
- `LibEventLoop`: This uses the `libevent` pecl extension. `libevent` itself supports a number of system-specific backends (epoll, kqueue).
- `LibEvLoop`: This uses the `libev` pecl extension ([github](https://github.com/m4rw3r/php-libev)). It supports the same backends as libevent.
- `ExtEventLoop`: This uses the `event` pecl extension. It supports the same backends as libevent.

All of the loops support these features:

- File descriptor polling
- One-off timers
- Periodic timers
- Deferred execution of callbacks

Usage
-----

[](#usage)

Here is an async HTTP server built with just the event loop.

```
    $loop = React\EventLoop\Factory::create();

    $server = stream_socket_server('tcp://127.0.0.1:8080');
    stream_set_blocking($server, 0);
    $loop->addReadStream($server, function ($server) use ($loop) {
        $conn = stream_socket_accept($server);
        $data = "HTTP/1.1 200 OK\r\nContent-Length: 3\r\n\r\nHi\n";
        $loop->addWriteStream($conn, function ($conn) use (&$data, $loop) {
            $written = fwrite($conn, $data);
            if ($written === strlen($data)) {
                fclose($conn);
                $loop->removeStream($conn);
            } else {
                $data = substr($data, $written);
            }
        });
    });

    $loop->addPeriodicTimer(5, function () {
        $memory = memory_get_usage() / 1024;
        $formatted = number_format($memory, 3).'K';
        echo "Current memory usage: {$formatted}\n";
    });

    $loop->run();
```

**Note:** The factory is just for convenience. It tries to pick the best available implementation. Libraries `SHOULD` allow the user to inject an instance of the loop. They `MAY` use the factory when the user did not supply a loop.

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor3

3 contributors hold 50%+ of commits

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

Recently: every ~240 days

Total

13

Last Release

3768d ago

PHP version history (3 changes)v0.1.0PHP &gt;=5.3.2

v0.2.0PHP &gt;=5.3.3

v0.4.0PHP &gt;=5.4.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/533d0c99c4e0c7413a1dcce2d81c37ecf94883e6377d274d6f43247a399bb268?d=identicon)[nick4fake](/maintainers/nick4fake)

---

Top Contributors

[![igorw](https://avatars.githubusercontent.com/u/88061?v=4)](https://github.com/igorw "igorw (46 commits)")[![nrk](https://avatars.githubusercontent.com/u/17923?v=4)](https://github.com/nrk "nrk (33 commits)")[![jmalloc](https://avatars.githubusercontent.com/u/761536?v=4)](https://github.com/jmalloc "jmalloc (30 commits)")[![cboden](https://avatars.githubusercontent.com/u/617694?v=4)](https://github.com/cboden "cboden (29 commits)")[![clue](https://avatars.githubusercontent.com/u/776829?v=4)](https://github.com/clue "clue (9 commits)")[![cebe](https://avatars.githubusercontent.com/u/189796?v=4)](https://github.com/cebe "cebe (6 commits)")[![WyriHaximus](https://avatars.githubusercontent.com/u/147145?v=4)](https://github.com/WyriHaximus "WyriHaximus (4 commits)")[![cameronjacobson](https://avatars.githubusercontent.com/u/2303661?v=4)](https://github.com/cameronjacobson "cameronjacobson (3 commits)")[![steverhoades](https://avatars.githubusercontent.com/u/1146668?v=4)](https://github.com/steverhoades "steverhoades (2 commits)")[![DaveRandom](https://avatars.githubusercontent.com/u/2396425?v=4)](https://github.com/DaveRandom "DaveRandom (1 commits)")[![lt](https://avatars.githubusercontent.com/u/1503065?v=4)](https://github.com/lt "lt (1 commits)")[![mkrauser](https://avatars.githubusercontent.com/u/494845?v=4)](https://github.com/mkrauser "mkrauser (1 commits)")[![greevex](https://avatars.githubusercontent.com/u/148401?v=4)](https://github.com/greevex "greevex (1 commits)")[![ondrejmirtes](https://avatars.githubusercontent.com/u/104888?v=4)](https://github.com/ondrejmirtes "ondrejmirtes (1 commits)")[![pborreli](https://avatars.githubusercontent.com/u/77759?v=4)](https://github.com/pborreli "pborreli (1 commits)")[![dandelionred](https://avatars.githubusercontent.com/u/19490344?v=4)](https://github.com/dandelionred "dandelionred (1 commits)")[![e3betht](https://avatars.githubusercontent.com/u/1811561?v=4)](https://github.com/e3betht "e3betht (1 commits)")

---

Tags

event-loopasynchronous

### Embed Badge

![Health badge](/badges/werkint-reactphp-event-loop/health.svg)

```
[![Health](https://phpackages.com/badges/werkint-reactphp-event-loop/health.svg)](https://phpackages.com/packages/werkint-reactphp-event-loop)
```

###  Alternatives

[react/event-loop

ReactPHP's core reactor event loop that libraries can use for evented I/O.

1.3k159.3M745](/packages/react-event-loop)[react/react

ReactPHP: Event-driven, non-blocking I/O with PHP.

9.1k3.7M65](/packages/react-react)[simple-bus/asynchronous

Generic classes and interfaces for asynchronous messaging using SimpleBus

241.6M6](/packages/simple-bus-asynchronous)[jaxon-php/jaxon-core

Jaxon is an open source PHP library for easily creating Ajax web applications

74149.4k29](/packages/jaxon-php-jaxon-core)[dmamontov/asynctask-7

AsyncTask enables proper and easy use of the thread. This class allows to perform background operations and publish results on the thread without having to manipulate threads and/or handlers.

1313.2k](/packages/dmamontov-asynctask-7)

PHPackages © 2026

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