PHPackages                             adamnicholson/kyew - 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. adamnicholson/kyew

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

adamnicholson/kyew
==================

0.2.0(9y ago)116.1k↓55.6%PHP

Since Apr 13Pushed 7y agoCompare

[ Source](https://github.com/adamnicholson/kyew)[ Packagist](https://packagist.org/packages/adamnicholson/kyew)[ RSS](/packages/adamnicholson-kyew/feed)WikiDiscussions master Synced today

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

Kyew
====

[](#kyew)

[![Build Status](https://camo.githubusercontent.com/64b1cd557850c7b83c6797d1e8fd754fdf33dd14e3c3fd451285884fcda08a6f/68747470733a2f2f7472617669732d63692e6f72672f6164616d6e6963686f6c736f6e2f6b7965772e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/adamnicholson/kyew)

Kyew is a thin layer on top of your existing *queue* package allowing you to push tasks to the queue and await the task completing.

Some examples where this could be useful include:

- Executing multiple tasks concurrently
- Pushing resource intensive tasks to a more performant server

Requirements
------------

[](#requirements)

- PHP7.0+
- A queue package (see [supported queues packages](#supported-queue-packages))

Example
-------

[](#example)

### Await a single task

[](#await-a-single-task)

```
$task = $kyew->async(function () {
    // Do some slow I/O operation
    return 'foo';
});
$response = $task->await(); // (string) "foo"
```

### Execute multiple tasks simultaneously

[](#execute-multiple-tasks-simultaneously)

```
$google = $kyew->async(function () {
    return file_get_contents('http://google.com');
});

$bbc = $kyew->async(function () {
    return file_get_contents('http://bbc.co.uk');
});

// Both closures have already started executing in the background

$google->await(); // (string) HTML source for Google's homepage
$bbc->await(); // (string) HTML source for BBC's homepage
```

How it Works
------------

[](#how-it-works)

When tasks are passed to `$task = $kyew->async($task)`, they are immediately handed off to the underlying queue package, along with an additional instruction to then store the task return value back into a persistance layer (eg. a database).

On calling `$task->await()`, we simply sit in a loop until either that value appears in the persistance layer, or until we reach the timeout threshold.

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

[](#installation)

Kyew can be installed with Composer

```
composer require adamnicholson/kyew

```

Kyew has two dependencies:

- A queue driver which [implements the `Kyew\Queue` interface](#supported-queue-packages)); used to hand jobs to your queue
- A pub-sub driver which [implements the `Kyew\PubSub` interface](#supported-persistence-layers); used to pass data between processes

The below example uses the `InMemoryPubSub` and `SynchronousQueue` queue - you should use implementations which suit your environment.

```
$pubsub = new Kyew\PubSub\InMemoryPubSub;
$kyew = new Kyew\Kyew(
    $pubsub,
    new Kyew\Queue\SynchronousQueue($pubsub)
);

$task = $this->kyew->async(function () {
    return 'Some return value!!!';
});
echo $task->await(); // string 'Some return value!!!'
```

API
---

[](#api)

### `Kyew::async(callable $task): Task`

[](#kyewasynccallable-task-task)

`async` accepts a single callable as its only parameter and will return an instance of `Task`.

```
$task = $kyew->async(function () {
    // Do some slow I/O operation
    return 'foo';
});
```

The callable is immediately handed to the queue library to be executed. The `Task` instance will listen to the queue process and be notified when the callable has finished executing.

### `Task::await(): void`

[](#taskawait-void)

`await` will block further code execution until the given Task has completed exectuing.

```
$response = $task->await();
echo $response; // (string) "foo"
```

Supported Queue Packages
------------------------

[](#supported-queue-packages)

- `IlluminateQueue`: Execute tasks in Laravel's (Illuminate) queue package
- `SynchronousQueue`: Execute tasks synchronously in the current process, mostly only used for testing

Supported persistence layers
----------------------------

[](#supported-persistence-layers)

- `DatabasePubSub`: Store task return values in a `PDO` compatible SQL database
- `RedisPubSub`: Store task return values in a redis server
- `InMemoryPubSub`: Store task return values in an in-memory PHP array, mostly only used for testing

Contributing
------------

[](#contributing)

We welcome any contributions to Kyew. They can be made via GitHub issues or pull requests.

License
-------

[](#license)

Kyew is licensed under the MIT License

Author
------

[](#author)

Adam Nicholson -

###  Health Score

30

—

LowBetter than 62% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity26

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity53

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

Total

2

Last Release

3323d ago

### Community

Maintainers

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

---

Top Contributors

[![adamnicholson](https://avatars.githubusercontent.com/u/7761178?v=4)](https://github.com/adamnicholson "adamnicholson (54 commits)")

---

Tags

asyncawaitlaravelphpphp7queue

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/adamnicholson-kyew/health.svg)

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

###  Alternatives

[league/geotools

Geo-related tools PHP 7.3+ library

1.4k5.6M31](/packages/league-geotools)[illuminate/bus

The Illuminate Bus package.

6046.3M542](/packages/illuminate-bus)[urbanindo/yii2-queue

Queue component for Yii2

11350.4k](/packages/urbanindo-yii2-queue)[hutnikau/job-scheduler

PHP job scheduler

7991.5k](/packages/hutnikau-job-scheduler)[belvg/module-sqs

N/A

1544.6k](/packages/belvg-module-sqs)[mayconbordin/l5-stomp-queue

Stomp Queue Driver for Laravel 5

121.1k](/packages/mayconbordin-l5-stomp-queue)

PHPackages © 2026

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