PHPackages                             zwirek/react-timer-handler - 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. zwirek/react-timer-handler

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

zwirek/react-timer-handler
==========================

Simple handler for ReactPHP timers

1.1.0(2y ago)1176↓100%MITPHPPHP &gt;=8.1

Since Aug 23Pushed 2y ago1 watchersCompare

[ Source](https://github.com/zwirek/reactphp-timer-handler)[ Packagist](https://packagist.org/packages/zwirek/react-timer-handler)[ RSS](/packages/zwirek-react-timer-handler/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (2)Versions (3)Used By (0)

ReactPHP Timer Handler
======================

[](#reactphp-timer-handler)

When `react/event-loop` timer is set, method will return object of the timer. It is important to hold reference to timer when you want to cancel this timer. But due to the nature of asynchronous live cycle of the process it is likely that reference will be overwritten by the new timer. ReactPHP Timer Handler introduce different approach to handle timers. Each timer has its unique name.

Usage examples
--------------

[](#usage-examples)

Add timer

```
$loop = \React\EventLoop\Factory::create();
$handler = new \Zwirek\React\Timer\Handler\TimerHandler($loop);

$success = $handler->addTimer('example_timer', 1, function (React\EventLoop\Timer\Timer $timer) {
    echo 'example_timer', PHP_EOL;
});

var_dump($success); //prints true

$loop->run();

echo 'done', PHP_EOL;
```

You can not overwrite your timer accidentally. When run, you will see output from the first timer only.

```
$loop = \React\EventLoop\Factory::create();
$handler = new \Zwirek\React\Timer\Handler\TimerHandler($loop);

$first = $handler->addTimer('example_timer', 1, function (React\EventLoop\Timer\Timer $timer) {
    echo 'first', PHP_EOL;
});

$second = $handler->addTimer('example_timer', 1, function (React\EventLoop\Timer\Timer $timer) {
    echo 'second', PHP_EOL;
});

var_dump($first); //prints true
var_dump($second); //prints false

$loop->run();

echo 'done', PHP_EOL;
```

Timer can be canceled by its name

```
$loop = \React\EventLoop\Factory::create();
$handler = new \Zwirek\React\Timer\Handler\TimerHandler($loop);

$timer = $handler->addTimer('example_timer', 1, function (React\EventLoop\Timer\Timer $timer) {
    echo 'example_timer', PHP_EOL;
});

$handler->cancelTimer('example_timer');

$loop->run();

echo 'done', PHP_EOL;
```

`react/event-loop` allow to register periodic timer. TimerHandler also allow to register periodic timer by name

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

$handler = new \Zwirek\React\Timer\Handler\TimerHandler($loop);

$timer = $handler->addPeriodicTimer('periodic_timer', 1, function (React\EventLoop\Timer\Timer $timer) {});

$loop->run();
```

It is possible to create periodic timer which will be executed limited number of times

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

$handler = new \Zwirek\React\Timer\Handler\TimerHandler($loop);

$timer = $handler->addLimitedPeriodicTimer('limited_periodic_timer', 1, function (React\EventLoop\Timer\Timer $timer) {}, 5);

$loop->run();
```

Above timer execute registered handler 5 times at intervals of 1 seconds

To cancel all registered times just simply run:

```
$handler->cancelAll();
```

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity68

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

Total

2

Last Release

854d ago

PHP version history (2 changes)1.0.0PHP ^7.1

1.1.0PHP &gt;=8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/20dc0d745ba97e3a11c00e27ad4c7af2884644ccc845d838748732e5969fd06c?d=identicon)[zwirek](/maintainers/zwirek)

---

Top Contributors

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

---

Tags

phpasyncreactphptimerhandlerreact

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/zwirek-react-timer-handler/health.svg)

```
[![Health](https://phpackages.com/badges/zwirek-react-timer-handler/health.svg)](https://phpackages.com/packages/zwirek-react-timer-handler)
```

###  Alternatives

[react/promise-timer

A trivial implementation of timeouts for Promises, built on top of ReactPHP.

34141.9M96](/packages/react-promise-timer)[clue/docker-react

Async, event-driven access to the Docker Engine API, built on top of ReactPHP.

113154.9k1](/packages/clue-docker-react)[badfarm/zanzara

Asynchronous PHP Telegram Bot Framework

2022.5k](/packages/badfarm-zanzara)[clue/reactphp-eventsource

Instant real-time updates. Lightweight EventSource client receiving live messages via HTML5 Server-Sent Events (SSE). Fast stream processing built on top of ReactPHP's event-driven architecture.

5818.5k3](/packages/clue-reactphp-eventsource)[recoil/react

Integrate Recoil with ReactPHP.

32274.4k12](/packages/recoil-react)[clue/multicast-react

Simple, event-driven multicast UDP message client and server for ReactPHP.

2569.0k3](/packages/clue-multicast-react)

PHPackages © 2026

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