PHPackages                             srdestino/waitable - 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. srdestino/waitable

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

srdestino/waitable
==================

A full JavaScript style Promises for PHP async code

1.0.2(3y ago)24MITPHPPHP &gt;=7.0.33

Since May 29Pushed 3y ago1 watchersCompare

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

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

Waitable
========

[](#waitable)

The Waitable class is used for asynchronous computing. A Waitable object has three states

- Fulfilled
- Rejected
- Running: `This is the default state when it's created`

This class is analogue to JavaScript Promise class

Installation
============

[](#installation)

You can install this library from Composer executing the following commands `composer require srdestino/waitable` then all you have to do is use this as in the following examples

Usage
=====

[](#usage)

Create a new Waitable
---------------------

[](#create-a-new-waitable)

```
$waitable = new Waitable(function (IWaitable $waitable){
  LongTask();
  $waitable->Resolve(null); // When you call this method it will mark the Waitable as Fulfilled
});
```

This will create a new Waitable and the function we pass to the constructor will be executed asynchronously

Wait until the Waitable is resolved
-----------------------------------

[](#wait-until-the-waitable-is-resolved)

```
$waitable = new Waitable(function (IWaitable $waitable){
  $waitable->Resolve("Test"); // When you call this method it will mark the waitable as Fulfilled
});

$result = $waitable->Wait();
echo $result; // It will print "Test"
```

Wait until all waitables are resolved
-------------------------------------

[](#wait-until-all-waitables-are-resolved)

```
$firstWaitable = new Waitable(function (IWaitable $waitable){
    $waitable->Resolve("First value");
});
$secondWaitable = new Waitable(function (IWaitable $waitable) use($secondValue){
    $waitable->Resolve("Second value");
});
list($firstResult, $secondResult) = Waitable::WaitAll([$firstWaitable, $secondWaitable]);

echo $firstResult; // "First value"
echo $secondResult; // "Second value"
```

The static method WaitAll receives an array of IWaitable and wait until all are fulfilled. This method will return an array with the values returned by all the waitables.

Collaborating &amp; Getting Help
================================

[](#collaborating--getting-help)

This is an open source library, so you can collaborate if you want, feel free to [create Pull Request](https://github.com/JoseHuertasDev/Waitable/pulls) or [open an issue](https://github.com/JoseHuertasDev/Waitable/issues) in case you need help or want to suggest something.

Apache
======

[](#apache)

If you want to enable pcntl in Apache you can refer to the following post I wrote in medium

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity46

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

Total

4

Last Release

1439d ago

Major Versions

0.0.0.1 → v1.0.02022-05-29

### Community

Maintainers

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

---

Top Contributors

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

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/srdestino-waitable/health.svg)

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

###  Alternatives

[nass600/get-id3

PHP library for handling audio/video files metadata

6133.0k3](/packages/nass600-get-id3)[sapistudio/seleniumstealth

2152.4k2](/packages/sapistudio-seleniumstealth)[alexwight/php-signalr-client

Signal R Client

2329.3k](/packages/alexwight-php-signalr-client)

PHPackages © 2026

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