PHPackages                             wyrihaximus/react-cron - 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. wyrihaximus/react-cron

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

wyrihaximus/react-cron
======================

⏱️ Cronlike scheduler running inside the ReactPHP Event Loop

5.3.0(9mo ago)4064.2k↑34.2%3[3 issues](https://github.com/WyriHaximus/reactphp-cron/issues)MITMakefilePHP ^8.4CI passing

Since Feb 25Pushed 6d ago1 watchersCompare

[ Source](https://github.com/WyriHaximus/reactphp-cron)[ Packagist](https://packagist.org/packages/wyrihaximus/react-cron)[ GitHub Sponsors](https://github.com/WyriHaximus)[ RSS](/packages/wyrihaximus-react-cron/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (10)Dependencies (11)Versions (22)Used By (0)

Cronlike scheduler running inside a ReactPHP Event Loop
=======================================================

[](#cronlike-scheduler-running-inside-a-reactphp-event-loop)

[![Continuous Integration](https://github.com/WyriHaximus/reactphp-cron/workflows/Continuous%20Integration/badge.svg)](https://github.com/WyriHaximus/reactphp-cron/workflows/Continuous%20Integration/badge.svg)[![Latest Stable Version](https://camo.githubusercontent.com/35b37228bf19d1110d98988f37ae9b06c2ed47f6df279a67b9714af22238ffd3/68747470733a2f2f706f7365722e707567782e6f72672f57797269486178696d75732f72656163742d63726f6e2f762f737461626c652e706e67)](https://packagist.org/packages/WyriHaximus/react-cron)[![Total Downloads](https://camo.githubusercontent.com/ea1f1db98b0f87eb4d1ac477270025c0c74cd59020f509d5807965bc2b1a5399/68747470733a2f2f706f7365722e707567782e6f72672f57797269486178696d75732f72656163742d63726f6e2f646f776e6c6f6164732e706e67)](https://packagist.org/packages/WyriHaximus/react-cron)[![Code Coverage](https://camo.githubusercontent.com/278c931ff3475a299ab7191ede0c598c1358aed3bdbfd00e71f5ad2d7022f56e/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f57797269486178696d75732f72656163747068702d63726f6e2f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/WyriHaximus/reactphp-cron/?branch=master)[![License](https://camo.githubusercontent.com/8dff68398e373fc8d646205f87732769f22ce28fcaea67ebb06abe11690d7124/68747470733a2f2f706f7365722e707567782e6f72672f57797269486178696d75732f72656163742d63726f6e2f6c6963656e73652e706e67)](https://packagist.org/packages/WyriHaximus/react-cron)

Install
=======

[](#install)

To install via [Composer](http://getcomposer.org/), use the command below, it will automatically detect the latest version and bind it with `^`.

```
composer require wyrihaximus/react-cron

```

Usage
=====

[](#usage)

Schedule actions within the ReactPHP Event Loop

```
use React\Promise\PromiseInterface;
use WyriHaximus\React\Cron;
use WyriHaximus\React\Cron\Action;

use function React\Promise\resolve;

Cron::create(
    new Action(
        'Hour', // Identifier used for mutex locking
        60, // TTL for the mutex lock, always set this way higher than the expected execution time, but low enough any failures during the run will cause issues
        '@hourly', // The cron expression used to schedule this action
        function (): PromiseInterface { // The callable ran when this action is due according to it's schedule
            echo 'Another hour has passed!', PHP_EOL;

            return resolve(true); // This callable MUST return a promise, which is used for releasing the mutex lock
        }
    ),
    new Action(
        'Minute',
        0.1,
        '* * * * *',
        function (): PromiseInterface {
            echo 'Another minute has passed!', PHP_EOL;

            return resolve(true);
        }
    )
);

// Stops scheduling new action runs
$cron->stop();
```

Factory methods
===============

[](#factory-methods)

- `Cron::create($loop, ...$actions)`: Cron with in-memory mutex.
- `Cron::createWithMutex($loop, $mutex, ...$actions)`: Cron with supplied mutex.

Mutex
=====

[](#mutex)

All mutexes must implement [`wyrihaximus/react-mutex`](https://packagist.org/packages/wyrihaximus/react-mutex) to provide additional implementations beyond the default in memory one. This is meant to do distributed locking of cron jobs.

Error handling
==============

[](#error-handling)

With promise v3 uncaught rejected promises will no longer bubble up. As a result the running con instance will now emit errors when they occur and those must be handled.

```
$cron = Cron::create(...$actions);
$cron->on('error', static function (Throwable $throwable): void {
    // Handle error
});
```

Run an action on start up and it's normal schedule
==================================================

[](#run-an-action-on-start-up-and-its-normal-schedule)

In certain edge causes you want to start an action at it's normal schedule and on start up. To facilitate that the `RunOnStartUpAction` will run at both moments. It's create exactly the same as an normal action, equally respects any mutex, but it will run one additional time when the event loop starts:

```
// Normal action
new Action(
    'Hour', // Identifier used for mutex locking
    60, // TTL for the mutex lock, always set this way higher than the expected execution time, but low enough any failures during the run will cause issues
    '@hourly', // The cron expression used to schedule this action
    function (): PromiseInterface { // The callable ran when this action is due according to it's schedule
        echo 'Another hour has passed!', PHP_EOL;

        return resolve(true); // This callable MUST return a promise, which is used for releasing the mutex lock
    }
);
// Run on start up action
new RunOnStartUpAction(
    'Hour', // Identifier used for mutex locking
    60, // TTL for the mutex lock, always set this way higher than the expected execution time, but low enough any failures during the run will cause issues
    '@hourly', // The cron expression used to schedule this action
    function (): PromiseInterface { // The callable ran when this action is due according to it's schedule
        echo 'Another hour has passed!', PHP_EOL;

        return resolve(true); // This callable MUST return a promise, which is used for releasing the mutex lock
    }
);
```

License
=======

[](#license)

The MIT License (MIT)

Copyright (c) 2026 Cees-Jan Kiewiet

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

###  Health Score

61

—

FairBetter than 98% of packages

Maintenance79

Regular maintenance activity

Popularity42

Moderate usage in the ecosystem

Community16

Small or concentrated contributor base

Maturity87

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 70.3% 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 ~219 days

Recently: every ~244 days

Total

12

Last Release

276d ago

Major Versions

1.0.0 → 2.0.02021-01-22

2.1.2 → 3.0.02021-08-10

3.1.0 → 4.0.02023-01-27

4.0.0 → 5.0.02024-04-12

PHP version history (7 changes)1.0.0PHP ^7.2

2.0.0PHP ^7.4

3.0.0PHP ^8 || ^7.4

4.0.0PHP ^8.1

5.0.0PHP ^8.2

5.2.0PHP ^8.3

5.3.0PHP ^8.4

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/147145?v=4)[Cees-Jan Kiewiet](/maintainers/WyriHaximus)[@WyriHaximus](https://github.com/WyriHaximus)

---

Top Contributors

[![WyriHaximus](https://avatars.githubusercontent.com/u/147145?v=4)](https://github.com/WyriHaximus "WyriHaximus (154 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (34 commits)")[![renovate-runner[bot]](https://avatars.githubusercontent.com/u/147145?v=4)](https://github.com/renovate-runner[bot] "renovate-runner[bot] (23 commits)")[![dependabot-preview[bot]](https://avatars.githubusercontent.com/in/2141?v=4)](https://github.com/dependabot-preview[bot] "dependabot-preview[bot] (3 commits)")[![dependabot-support](https://avatars.githubusercontent.com/u/112581971?v=4)](https://github.com/dependabot-support "dependabot-support (2 commits)")[![renovate[bot]](https://avatars.githubusercontent.com/in/2740?v=4)](https://github.com/renovate[bot] "renovate[bot] (2 commits)")[![olshevskiy87](https://avatars.githubusercontent.com/u/26171315?v=4)](https://github.com/olshevskiy87 "olshevskiy87 (1 commits)")

---

Tags

cronhacktoberfestphpphp7reactphp

### Embed Badge

![Health badge](/badges/wyrihaximus-react-cron/health.svg)

```
[![Health](https://phpackages.com/badges/wyrihaximus-react-cron/health.svg)](https://phpackages.com/packages/wyrihaximus-react-cron)
```

###  Alternatives

[ccxt/ccxt

A cryptocurrency trading API with more than 100 exchanges in JavaScript / TypeScript / Python / C# / PHP / Go

43.2k341.0k1](/packages/ccxt-ccxt)[composer/composer

Composer helps you declare, manage and install dependencies of PHP projects. It ensures you have the right stack everywhere.

29.5k196.2M3.1k](/packages/composer-composer)[friendsofphp/php-cs-fixer

A tool to automatically fix PHP code style

13.5k251.2M25.3k](/packages/friendsofphp-php-cs-fixer)[team-reflex/discord-php

An unofficial API to interact with the voice and text service Discord.

1.1k420.9k26](/packages/team-reflex-discord-php)[ecotone/ecotone

Enterprise architecture layer for Laravel and Symfony — CQRS, Event Sourcing, Durable Workflows (Sagas, Orchestrators), Projections, and Outbox messaging via PHP attributes.

564576.7k53](/packages/ecotone-ecotone)[internal/dload

Downloads binaries.

102212.3k19](/packages/internal-dload)

PHPackages © 2026

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