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

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

ucscode/promise
===============

A lightweight and concise implementation of Promises in PHP

1.0.0(2y ago)1101MITPHPPHP &gt;=8.1

Since Jan 22Pushed 2y ago1 watchersCompare

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

READMEChangelogDependenciesVersions (2)Used By (1)

Promise
=======

[](#promise)

Promise is a simple and lightweight implementation of Javascript Promises in PHP. Promises provide a clean and structured way to work with asynchronous operations, allowing you to handle deferred execution and manage asynchronous workflows more effectively.

Features
--------

[](#features)

- **Promises/A+ Compliant:** Follows the Promises/A+ specification for consistent behavior.
- **Chaining:** Chain promises together using the `then` method.
- **Error Handling:** Handle errors using the `catch` method.
- **Finalization:** Execute code regardless of the promise's state with the `finally` method.

Getting Started
---------------

[](#getting-started)

### Installation

[](#installation)

```
composer require ucscode/promise
```

### Usage

[](#usage)

```
use Ucscode\Promise\Promise;

$promise = new Promise(function ($resolve, $reject) {
    // Asynchronous operation
    sleep(20);
    $resolve("Operation Successful");
});

$promise->then(
    fn ($value) => "Fulfilled: $value",
    fn ($reason) => "Rejected: $reason"
)
->finally(fn () => "Operation complete");
```

### Multiple Promises

[](#multiple-promises)

The `Promise::all` method takes an array of promises, and collects their fulfilled values. If all promises are fulfilled, it resolves with an array of fulfilled values. If any promise is rejected, it rejects with the reason of the first rejected promise.

```
$promises = [
    new Promise(function ($resolve) { $resolve(1); }),
    new Promise(function ($resolve) { $resolve(2); }),
    new Promise(function ($resolve) { $resolve(3); }),
];

Promise::all($promises)->then(
    function ($values) {
        // All promises fulfilled
        var_dump($values); // Output: array(1, 2, 3)
    },
    fn ($reason) => "At least one promise rejected"
);
```

### Contributing

[](#contributing)

Contributions are welcome! Feel free to open issues or pull requests.

### License

[](#license)

This project is licensed under the [MIT License](https://opensource.org/license/mit/)

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity50

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

Unknown

Total

1

Last Release

847d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/65673b1b31e87471999a7614d107e7e061a38bf72191d149c66c1b943124e09c?d=identicon)[ucscode](/maintainers/ucscode)

---

Top Contributors

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

### Embed Badge

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

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

###  Alternatives

[trafiklab/gtfs-php-sdk

Use GTFS and GTFS-realtime data in your PHP projects

175.3k](/packages/trafiklab-gtfs-php-sdk)

PHPackages © 2026

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