PHPackages                             danog/async-construct - 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. danog/async-construct

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

danog/async-construct
=====================

Async class constructor and wakeup functions for AMPHP.

0.1.0(5y ago)04MITPHPPHP &gt;=7.1CI failing

Since Jul 31Pushed 5y agoCompare

[ Source](https://github.com/danog/asyncConstruct)[ Packagist](https://packagist.org/packages/danog/async-construct)[ Docs](https://github.com/danog/asyncConstruct)[ GitHub Sponsors](https://github.com/danog)[ RSS](/packages/danog-async-construct/feed)WikiDiscussions master Synced 1w ago

READMEChangelogDependencies (5)Versions (2)Used By (0)

AsyncConstruct
==============

[](#asyncconstruct)

[![Build status](https://github.com/danog/asyncConstruct/workflows/build/badge.svg)](https://github.com/danog/asyncConstruct/workflows/build/badge.svg)[![codecov](https://camo.githubusercontent.com/5d3ee86c1f514f0ce718e47aa56c95c88dcf37b6070faac3db462e3146d4e70a/68747470733a2f2f636f6465636f762e696f2f67682f64616e6f672f6173796e63436f6e7374727563742f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/danog/asyncConstruct)[![License](https://camo.githubusercontent.com/7013272bd27ece47364536a221edb554cd69683b68a46fc0ee96881174c4214c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667)](https://camo.githubusercontent.com/7013272bd27ece47364536a221edb554cd69683b68a46fc0ee96881174c4214c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667)

`danog/asyncConstruct` provides async class constructor and wakeup functions for AMPHP.

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

[](#installation)

```
composer require danog/async-construct
```

API
---

[](#api)

- Async
    - [AsyncConstruct](#AsyncConstruct)
    - [AsyncWakeup](#AsyncWakeup)
- Blocking
    - [BlockingConstruct](#BlockingConstruct)
    - [BlockingWakeup](#BlockingWakeup)

### AsyncConstruct

[](#asyncconstruct-1)

[Example](https://github.com/danog/asyncConstruct/blob/master/examples/async.php)

Simply `use` this trait in your class, and define a `__construct_async` async method.
The trait will automatically run the async method on construction, and expose a set of APIs to wait on the result of the constructor for initialization.

#### `init()`

[](#init)

Will blockingly wait for execution of the async constructor, returning its return value.

#### `initAsynchronously()`

[](#initasynchronously)

Will return a promise that, when `yield`ed, will wait for and return the return value of the constructor.

#### `inited()`

[](#inited)

Returns a boolean, indicating whether the class was initialized or not.

### BlockingConstruct

[](#blockingconstruct)

[Example](https://github.com/danog/asyncConstruct/blob/master/examples/blocking.php)

Exactly like [AsyncConstruct](#AsyncConstruct), except that the blocking `init()` function will be automatically called on construction.

### AsyncWakeup

[](#asyncwakeup)

[Example](https://github.com/danog/asyncConstruct/blob/master/examples/asyncWakeup.php)

Simply `use` this trait in your class, and define a `__wakeup_async` async method.
The trait will automatically run the async method on deserialization, and expose a set of APIs to wait on the result of the wakeup function for re-initialization.

#### `wakeup()`

[](#wakeup)

Will blockingly wait for execution of the async wakeup function, returning its return value.

#### `wakeupAsynchronously()`

[](#wakeupasynchronously)

Will return a promise that, when `yield`ed, will wait for and return the return value of the wakeup function.

#### `wokenUp()`

[](#wokenup)

Returns a boolean, indicating whether the class was initialized or not.

### BlockingWakeup

[](#blockingwakeup)

[Example](https://github.com/danog/asyncConstruct/blob/master/examples/blockingWakeup.php)

Exactly like [AsyncWakeup](#AsyncWakeup), except that the blocking `wakeup()` function will be automatically called on wakeup.

###  Health Score

19

—

LowBetter than 10% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity40

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

2117d ago

### Community

Maintainers

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

---

Top Contributors

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

---

Tags

asyncasynchronousconcurrentmulti-threadingmulti-processing

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Type Coverage Yes

### Embed Badge

![Health badge](/badges/danog-async-construct/health.svg)

```
[![Health](https://phpackages.com/badges/danog-async-construct/health.svg)](https://phpackages.com/packages/danog-async-construct)
```

###  Alternatives

[amphp/parallel

Parallel processing component for Amp.

85046.2M74](/packages/amphp-parallel)[amphp/amp

A non-blocking concurrency framework for PHP applications.

4.4k123.4M323](/packages/amphp-amp)[revolt/event-loop

Rock-solid event loop for concurrent PHP applications.

92343.6M138](/packages/revolt-event-loop)[danog/ipc

IPC component for Amp.

11680.1k6](/packages/danog-ipc)[amphp/sync

Non-blocking synchronization primitives for PHP based on Amp and Revolt.

19052.8M39](/packages/amphp-sync)[amphp/serialization

Serialization tools for IPC and data storage in PHP.

13551.1M18](/packages/amphp-serialization)

PHPackages © 2026

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