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

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

dazzle-php/loop
===============

Dazzle Asynchronous I/O Event Loop.

v0.4.1(8y ago)63.8k↓100%1MITPHPPHP &gt;=5.6.7

Since Sep 16Pushed 8y ago1 watchersCompare

[ Source](https://github.com/dazzle-php/loop)[ Packagist](https://packagist.org/packages/dazzle-php/loop)[ Docs](http://kraken-php.com)[ RSS](/packages/dazzle-php-loop/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (1)Versions (10)Used By (0)

Dazzle Async I/O Event Loop
===========================

[](#dazzle-async-io-event-loop)

[![Build Status](https://camo.githubusercontent.com/1c6385e44e0609c41a745e668c166fe368014b920f787d0e445613b6c52ac647/68747470733a2f2f7472617669732d63692e6f72672f64617a7a6c652d7068702f6c6f6f702e737667)](https://travis-ci.org/dazzle-php/loop)[![Code Coverage](https://camo.githubusercontent.com/d0eb18fefb8bde204f77b628a5b3bcb07017de509098ee098b72981a8a27a0fa/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f64617a7a6c652d7068702f6c6f6f702f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/dazzle-php/loop/?branch=master)[![Code Quality](https://camo.githubusercontent.com/a7c0dca52244b288ffbc870c0c36647cf1a9db543414952ac9bbc30837de612b/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f64617a7a6c652d7068702f6c6f6f702f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/dazzle-php/loop/?branch=master)[![Latest Stable Version](https://camo.githubusercontent.com/d5e4fc6f2caad432054c94c3ca6fc3e7c1e9a72696ee714a61f5b57192a6cc87/68747470733a2f2f706f7365722e707567782e6f72672f64617a7a6c652d7068702f6c6f6f702f762f737461626c65)](https://packagist.org/packages/dazzle-php/loop)[![Latest Unstable Version](https://camo.githubusercontent.com/fc675070602c2ae309809372593acd37ce497a2064e878f4947431ef237d62aa/68747470733a2f2f706f7365722e707567782e6f72672f64617a7a6c652d7068702f6c6f6f702f762f756e737461626c65)](https://packagist.org/packages/dazzle-php/loop)[![License](https://camo.githubusercontent.com/3f54f29784fddcaf71c4eec7af98345436b7b4430e4650220c8e0e70adfa3af7/68747470733a2f2f706f7365722e707567782e6f72672f64617a7a6c652d7068702f6c6f6f702f6c6963656e7365)](https://packagist.org/packages/dazzle-php/loop/license)

> **Note:** This repository is part of [Dazzle Project](https://github.com/dazzle-php/dazzle) - the next-gen library for PHP. The project's purpose is to provide PHP developers with a set of complete tools to build functional async applications. Please, make sure you read the attached README carefully and it is guaranteed you will be surprised how easy to use and powerful it is. In the meantime, you might want to check out the rest of our async libraries in [Dazzle repository](https://github.com/dazzle-php) for the full extent of Dazzle experience.

[![](https://raw.githubusercontent.com/dazzle-php/dazzle/master/media/dazzle-x125.png)](https://raw.githubusercontent.com/dazzle-php/dazzle/master/media/dazzle-x125.png)

Description
-----------

[](#description)

Dazzle Loop is a component that provides abstraction layer for writing asynchronous code in PHP on single thread or process with usage of single or multiple loops.

Feature Highlights
------------------

[](#feature-highlights)

Dazzle Loop features:

- Interface for writing asynchronous code on single Thread or Process,
- File descriptor polling,
- One-time and periodic timers,
- Deferred execution of callbacks,
- Support for StreamSelect -based loops,
- Support for LibEvent -based loops,
- Support for LibEv -based loops,
- Support for ExtEvent -based loops,
- Support for combining multiple loops and managing them from one wrapper,
- Support for switching between multiple execution flows,
- ReactPHP Event-Loop adapters,
- ReactPHP compatibility,
- ...and more.

Provided Example(s)
-------------------

[](#provided-examples)

### Quickstart

[](#quickstart)

This example shows implementation of non-blocking clock using loop:

```
$loop = new Loop();

$loop->addPeriodicTimer(1, function() {
    printf("\rCurrent clock: %s", date('Y-m-d H:i:s'));
});

$loop->start();
```

### Additional

[](#additional)

Additional examples can be found in [example](https://github.com/dazzle-php/loop/tree/master/example) directory. Below is the list of provided examples as a reference and preferred consumption order:

- [Quickstart](https://github.com/dazzle-php/loop/blob/master/example/loop_quickstart.php)
- [Using Loop start/stop events](https://github.com/dazzle-php/loop/blob/master/example/loop_using_events.php)
- [Scheduling simple timers](https://github.com/dazzle-php/loop/blob/master/example/loop_using_simple_timers.php)
- [Scheduling periodic timers](https://github.com/dazzle-php/loop/blob/master/example/loop_using_periodic_timers.php)
- [Scheduling periodic timers with manual control](https://github.com/dazzle-php/loop/blob/master/example/loop_using_periodic_timers_controls.php)
- [Cancelling timers](https://github.com/dazzle-php/loop/blob/master/example/loop_cancelling_timers.php)
- [Cancelling timers alternatively](https://github.com/dazzle-php/loop/blob/master/example/loop_cancelling_timers_alternative.php)
- [Queueing tick listeners](https://github.com/dazzle-php/loop/blob/master/example/loop_listening_on_ticks.php)
- [Queueing tick listeners to begin/end of queue](https://github.com/dazzle-php/loop/blob/master/example/loop_listening_on_ticks_all.php)
- [Using streams asynchronously - pt 1](https://github.com/dazzle-php/loop/blob/master/example/loop_io_stream_source.php)
- [Using streams asynchronously - pt 2](https://github.com/dazzle-php/loop/blob/master/example/loop_io_stream_pipe.php)
- [**Advanced:** Implementing simple HTTP server](https://github.com/dazzle-php/loop/blob/master/example/loop_http_server.php)

If any of the above examples has left you confused, please take a look in the [tests](https://github.com/dazzle-php/loop/tree/master/test) directory as well.

Comparison
----------

[](#comparison)

This section contains Dazzle vs React comparison many users requested. If you are wondering why this section has been created, see the [author's note](https://github.com/dazzle-php/dazzle/blob/master/NOTE.md).

#### Performance

[](#performance)

[![](https://raw.githubusercontent.com/dazzle-php/loop/master/media/graph-perf-cpu.png)](https://raw.githubusercontent.com/dazzle-php/loop/master/media/graph-perf-cpu.png)

The detailed information about this benchmark can be found in [benchmark-on.php](https://github.com/dazzle-php/loop/blob/master/example-bench/benchmark.php) and [benchmark-react.php](https://github.com/dazzle-php/loop/blob/master/example-bench/benchmark-react.php) files.

#### Memory Allocation Efficiency

[](#memory-allocation-efficiency)

[![](https://raw.githubusercontent.com/dazzle-php/loop/master/media/graph-perf-mem.png)](https://raw.githubusercontent.com/dazzle-php/loop/master/media/graph-perf-mem.png)

The detailed information about this benchmark can be found in [benchmark-once.php](https://github.com/dazzle-php/loop/blob/master/example-bench/benchmark.php) and [benchmark-react.php](https://github.com/dazzle-php/loop/blob/master/example-bench/benchmark-react.php) files.

#### Details

[](#details)

DetailDazzle EventReact-equivalentActive supportX?Provided well-formed documentationXXProvided well-formed set of tests with at least 80% coverage and API examplesXXSupport for executing event ticksXXSupport for before and after event ticks listenersXXSupport for timersXXSupport for periodic timersXXAsynchronous writing of streamsXXAsynchronous reading of streamsXXCancelling timersXXImplemented stream modelXXImplemented lib-event modelWIPXImplemented lib-ev modelWIPXImplemented ext-event modelWIPXSupport for state change eventsXSupport for flow controlsXSupport for multiple flows and switching between active onesXRequirements
------------

[](#requirements)

Loop requires:

- PHP-5.6 or PHP-7.0+,
- UNIX or Windows OS.

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

[](#installation)

To install this library make sure you have [composer](https://getcomposer.org/) installed, then run following command:

```
$> composer require dazzle-php/loop

```

Tests
-----

[](#tests)

Tests can be run via:

```
$> vendor/bin/phpunit -d memory_limit=1024M

```

Versioning
----------

[](#versioning)

Versioning of Dazzle libraries is described in versioning section of [Dazzle Project](https://github.com/dazzle-php/dazzle) index repository. Please, refer there for detailed information on the subject.

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

[](#contributing)

Thank you for considering contributing to this repository!

- The contribution guide can be found in the [contribution tips](https://github.com/dazzle-php/loop/blob/master/CONTRIBUTING.md).
- Open tickets can be found in [issues section](https://github.com/dazzle-php/loop/issues).
- Current contributors are listed in [graphs section](https://github.com/dazzle-php/loop/graphs/contributors)
- To contact the author(s) see the information attached in [composer.json](https://github.com/dazzle-php/loop/blob/master/composer.json) file.

License
-------

[](#license)

Dazzle Loop is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT).

---

*"Everything is possible. The impossible just takes longer."* ― Dan Brown

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity25

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity54

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

Every ~35 days

Recently: every ~63 days

Total

9

Last Release

3240d ago

PHP version history (2 changes)v0.3.0PHP &gt;=5.5.9

0.4.x-devPHP &gt;=5.6.7

### Community

Maintainers

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

---

Top Contributors

[![khelle](https://avatars.githubusercontent.com/u/5642657?v=4)](https://github.com/khelle "khelle (43 commits)")

---

Tags

asyncdazzleeventevent-looploopphpphp-libphp7queueselectstream-selecteventevent-loopasyncasynchronousloopkrakenkraken-phplibeventlibev

### Embed Badge

![Health badge](/badges/dazzle-php-loop/health.svg)

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

###  Alternatives

[amphp/amp

A non-blocking concurrency framework for PHP applications.

4.4k123.4M321](/packages/amphp-amp)[revolt/event-loop

Rock-solid event loop for concurrent PHP applications.

91943.6M138](/packages/revolt-event-loop)[icicleio/icicle

Icicle is a PHP library for writing asynchronous code using synchronous coding techniques.

1.1k150.9k14](/packages/icicleio-icicle)[recoil/recoil

Asynchronous coroutines for PHP 7.

78961.5k7](/packages/recoil-recoil)[recoil/react

Integrate Recoil with ReactPHP.

32274.4k12](/packages/recoil-react)[async-interop/event-loop

An event loop interface for interoperability.

1695.8k4](/packages/async-interop-event-loop)

PHPackages © 2026

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