PHPackages                             fyre/promise - 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. fyre/promise

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

fyre/promise
============

An promise library.

v4.0.2(6mo ago)1201MITPHP

Since May 13Pushed 6mo ago1 watchersCompare

[ Source](https://github.com/elusivecodes/FyrePromise)[ Packagist](https://packagist.org/packages/fyre/promise)[ RSS](/packages/fyre-promise/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (4)Versions (26)Used By (1)

FyrePromise
===========

[](#fyrepromise)

**FyrePromise** is a free, open-source promise library for *PHP*.

It is a modern library, and features support for synchronous and asynchronous promises.

Table Of Contents
-----------------

[](#table-of-contents)

- [Installation](#installation)
- [Basic Usage](#basic-usage)
- [Methods](#methods)
- [Async Promises](#async-promises)
- [Static Methods](#static-methods)

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

[](#installation)

**Using Composer**

```
composer require fyre/promise

```

In PHP:

```
use Fyre\Promise\Promise;
```

Basic Usage
-----------

[](#basic-usage)

- `$callback` is a *Closure*.

```
$promise = new Promise($callback);
```

The `$callback` should be expressed in the following format:

```
$callback = function(Closure $resolve, Closure $reject): void {
    $resolve();
};
```

Methods
-------

[](#methods)

**Catch**

Execute a callback if the *Promise* is rejected.

- `$onRejected` is a *Closure* that will execute when the *Promise* is rejected.

```
$promise->catch($onRejected);
```

This method will return a new *Promise*.

**Finally**

Execute a callback when the *Promise* is settled.

- `$onFinally` is a *Closure* that will execute when the *Promise* has settled.

```
$promise->finally($onFinally);
```

This method will return a new *Promise*.

**Then**

Execute a callback when the *Promise* is resolved.

- `$onFulfilled` is a *Closure* that will execute when the *Promise* is resolved.
- `$onRejected` is a *Closure* that will execute when the *Promise* is rejected, and will default to *null*.

```
$promise->then($onFulfilled, $onRejected);
```

This method will return a new *Promise*.

Async Promises
--------------

[](#async-promises)

The `\Fyre\Promise\AsyncPromise` class extends the *Promise* class, while providing additional methods for handling asynchronous operations.

```
use \Fyre\Promise\AsyncPromise;

$promise = new AsyncPromise(function(Closure $resolve, Closure $reject): void {
    // this will be executed on a forked process
    sleep(3);

    $resolve(1);
})->then(function(int $value): void {
    // this will be executed on the main thread

    echo $value;
});

$promise->wait();
```

**Cancel**

Cancel the pending *AsyncPromise*.

- `$message` is a string representing the cancellation message.

```
$promise->cancel($message);
```

A cancelled promise will reject with a `Fyre\Promise\Exceptions\CancelledPromiseException`.

**Wait**

Wait for the *AsyncPromise* to settle.

```
$promise->wait();
```

Static Methods
--------------

[](#static-methods)

**Any**

Wait for any promise to resolve.

- `$promises` is an iterable containing the promises or values to wait for.

```
$promise = Promise::any($promises);
```

This method will return a new *Promise*.

**All**

Wait for all promises to resolve.

- `$promises` is an iterable containing the promises or values to wait for.

```
$promise = Promise::all($promises);
```

This method will return a new *Promise*.

**Await**

Wait for a *Promise* to settle.

- `$promise` is the *Promise* to wait for.

```
try {
    $resolvedValue = Promise::await($promise);
} catch (Throwable $reason) {
    //...
}
```

**Race**

Wait for the first promise to resolve.

- `$promises` is an iterable containing the promises or values to wait for.

```
$promise = Promise::all($promises);
```

This method will return a new *Promise*.

**Reject**

Create a *Promise* that rejects.

- `$reason` is a *Throwable* representing the rejected reason, and will default to *null*.

```
$promise = Promise::reject($reason);
```

**Resolve**

Create a *Promise* that resolves.

- `$value` is the resolved value, and will default to *null*.

```
$promise = Promise::resolve($value);
```

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance66

Regular maintenance activity

Popularity8

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity58

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

Recently: every ~24 days

Total

25

Last Release

197d ago

Major Versions

v1.0.2 → v2.02023-07-08

v2.0.8 → v3.02024-10-25

v3.0.9 → v4.02025-10-20

### Community

Maintainers

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

---

Top Contributors

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

---

Tags

asyncphppromise

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/fyre-promise/health.svg)

```
[![Health](https://phpackages.com/badges/fyre-promise/health.svg)](https://phpackages.com/packages/fyre-promise)
```

PHPackages © 2026

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