PHPackages                             symplely/thread\_queue - 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. symplely/thread\_queue

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

symplely/thread\_queue
======================

An simply `uv\_queue\_work` wrapper API to manage a pool of threads, for parallel PHP execution

149PHP

Since Mar 19Pushed 3y ago1 watchersCompare

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

READMEChangelogDependenciesVersions (1)Used By (0)

thread\_queue
=============

[](#thread_queue)

[![Linux](https://github.com/symplely/thread_queue/workflows/Linux/badge.svg)](https://github.com/symplely/thread_queue/actions?query=workflow%3ALinux)[![Windows](https://github.com/symplely/thread_queue/workflows/Windows/badge.svg)](https://github.com/symplely/thread_queue/actions?query=workflow%3AWindows)[![macOS](https://github.com/symplely/thread_queue/workflows/macOS/badge.svg)](https://github.com/symplely/thread_queue/actions?query=workflow%3AmacOS)[![Codacy Badge](https://camo.githubusercontent.com/077052a407ad19c422592fe5b6e1ee2a00be161448989196f2d33932b8bc8e49/68747470733a2f2f6170702e636f646163792e636f6d2f70726f6a6563742f62616467652f47726164652f3363383934303862393738323462363962343537393135306634303135646134)](https://app.codacy.com/gh/symplely/thread_queue/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade)[![Maintainability](https://camo.githubusercontent.com/574c8127bcb8821ad2d05af53a6c59619885c89be8bbe2429a7d9e99c9d22207/68747470733a2f2f6170692e636f6465636c696d6174652e636f6d2f76312f6261646765732f64653232616438333237613336356465313334302f6d61696e7461696e6162696c697479)](https://codeclimate.com/github/symplely/thread_queue/maintainability)

An simply **`uv_queue_work`** wrapper API to *manage* a **pool** of **threads**, for parallel PHP *execution*.

Table of Contents
-----------------

[](#table-of-contents)

- [Installation](#installation)
- [Usage](#usage)
- [Event hooks](#event-hooks)
- [Contributing](#contributing)
- [License](#license)

This package uses features of [`libuv`](https://github.com/libuv/libuv), the PHP extension [ext-uv](https://github.com/amphp/ext-uv) of the **Node.js** library. It's `uv_queue_work` function is used to create Threads.

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

[](#installation)

```
composer require symplely/thread_queue
```

This package will require **libuv** features, do one of the following to install.

For **Debian** like distributions, Ubuntu...

```
apt-get install libuv1-dev php-pear -y
```

For **RedHat** like distributions, CentOS...

```
yum install libuv-devel php-pear -y
```

Now have **Pecl** auto compile, install, and setup.

```
pecl channel-update pecl.php.net
pecl install uv-beta
```

For **Windows**, stable PHP versions are available [from PECL](https://pecl.php.net/package/uv).

Directly download latest from

Extract `libuv.dll` to same directory as `PHP` binary executable, and extract `php_uv.dll` to `ext\` directory.

Enable extension `php_uv.dll` in php.ini

```
cd C:\Php
Invoke-WebRequest "https://windows.php.net/downloads/pecl/releases/uv/0.2.4/php_uv-0.2.4-7.2-ts-vc15-x64.zip" -OutFile "php_uv-0.2.4.zip"
#Invoke-WebRequest "https://windows.php.net/downloads/pecl/releases/uv/0.2.4/php_uv-0.2.4-7.4-ts-vc15-x64.zip" -OutFile "php_uv-0.2.4.zip"
7z x -y php_uv-0.2.4.zip libuv.dll php_uv.dll
copy php_uv.dll ext\php_uv.dll
del php_uv.dll
del php_uv-0.2.4.zip
echo extension=uv >> php.ini
```

Usage
-----

[](#usage)

```
include 'vendor/autoload.php';

use Async\Threads\Thread;

$thread = new Thread();
$counter = 0;
$t1 = $thread->create_ex(function () {
  print "Running Thread: 1\n";
  return 2;
})->then(function (int $output) use (&$counter) {
  $counter += $output;
})->catch(function (\Throwable $e) {
  print $e->getMessage() . PHP_EOL;
});

$t1->join();
// Or
$t1->cancel();

print_r($t1->result());
// Or
print_r($t1->exception());
```

Event hooks
-----------

[](#event-hooks)

When creating Threads processes, you'll get an instance of `TWorker` returned. You can add the following event **callback** hooks on a `Thread` instance.

```
$thread = new Thread($function, ...$args)

$worker = $thread->create($thread_id /* string or int */, function () {
    }, ...$arguments)
    ->then(function ($result) {
        // On success, `$result` is returned by the thread.
    })
    ->catch(function ($exception) {
        // When an exception is thrown from within a thread, it's caught and passed here.
    });

$worker = $thread->create_ex(function () {
    }, ...$arguments)
    ->then(function ($result) {
        // On success, `$result` is returned by the thread.
    })
    ->catch(function ($exception) {
        // When an exception is thrown from within a thread, it's caught and passed here.
    });
```

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

[](#contributing)

Contributions are encouraged and welcome; I am always happy to get feedback or pull requests on Github :) Create [Github Issues](https://github.com/symplely/thread_queue/issues) for bugs and new features and comment on the ones you are interested in.

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

16

—

LowBetter than 5% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity23

Early-stage or recently created project

 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/b1a9d88c23f07f785e0358746ae2384950a6f8dac0c3bd4fbbc910e94f7eb637?d=identicon)[techno-express](/maintainers/techno-express)

---

Top Contributors

[![TheTechsTech](https://avatars.githubusercontent.com/u/29784725?v=4)](https://github.com/TheTechsTech "TheTechsTech (24 commits)")

### Embed Badge

![Health badge](/badges/symplely-thread-queue/health.svg)

```
[![Health](https://phpackages.com/badges/symplely-thread-queue/health.svg)](https://phpackages.com/packages/symplely-thread-queue)
```

###  Alternatives

[league/geotools

Geo-related tools PHP 7.3+ library

1.4k5.3M26](/packages/league-geotools)[amphp/parser

A generator parser to make streaming parsers simple.

14952.8M16](/packages/amphp-parser)[amphp/serialization

Serialization tools for IPC and data storage in PHP.

13451.1M18](/packages/amphp-serialization)[enqueue/enqueue

Message Queue Library

19820.0M56](/packages/enqueue-enqueue)[deliciousbrains/wp-background-processing

WP Background Processing can be used to fire off non-blocking asynchronous requests or as a background processing tool, allowing you to queue tasks.

1.1k409.8k6](/packages/deliciousbrains-wp-background-processing)[react/async

Async utilities and fibers for ReactPHP

2238.8M171](/packages/react-async)

PHPackages © 2026

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