PHPackages                             alicemajere/wonderland-thread - 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. alicemajere/wonderland-thread

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

alicemajere/wonderland-thread
=============================

Simple multi-threading management library

1.0.0(7y ago)1152[1 issues](https://github.com/AliceMajere/wonderland-thread/issues)[1 PRs](https://github.com/AliceMajere/wonderland-thread/pulls)MITPHPPHP &gt;=7.2

Since Oct 20Pushed 7y ago2 watchersCompare

[ Source](https://github.com/AliceMajere/wonderland-thread)[ Packagist](https://packagist.org/packages/alicemajere/wonderland-thread)[ RSS](/packages/alicemajere-wonderland-thread/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (2)Dependencies (4)Versions (3)Used By (0)

[![Build Status](https://camo.githubusercontent.com/044859d6f71d1a86c9b00e5112d6f861216420262c21ce9a016c1dbe35c97f9d/68747470733a2f2f7472617669732d63692e6f72672f416c6963654d616a6572652f776f6e6465726c616e642d7468726561642e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/AliceMajere/wonderland-thread)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/634ff58c11bab388a73f1ea3ffdaea5aa2701637fa845af055960c9cb683576c/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f416c6963654d616a6572652f776f6e6465726c616e642d7468726561642f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/AliceMajere/wonderland-thread/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/2053fdad61d025856e9d8595e6de5b6830ff67c559724d5c1c7ca3540e0efa1c/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f416c6963654d616a6572652f776f6e6465726c616e642d7468726561642f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/AliceMajere/wonderland-thread/?branch=master)[![Code Intelligence Status](https://camo.githubusercontent.com/7dd39f0caf0c9cc78e4c9bdee76549f699ea2ea4c34d9348148374b665931da5/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f416c6963654d616a6572652f776f6e6465726c616e642d7468726561642f6261646765732f636f64652d696e74656c6c6967656e63652e7376673f623d6d6173746572)](https://scrutinizer-ci.com/code-intelligence)[![License](https://camo.githubusercontent.com/250d352418b73f8395af0748df4a1bacded3fecde36bd8355ff27c256c45e670/68747470733a2f2f706f7365722e707567782e6f72672f616c6963656d616a6572652f776f6e6465726c616e642d7468726561642f6c6963656e7365)](https://packagist.org/packages/alicemajere/wonderland-thread)

Wonderland Thread
=================

[](#wonderland-thread)

A small simple multi-threading library to include in projects

Recent Update
-------------

[](#recent-update)

The project just got released on packagist with release 1.0.0.

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

[](#installation)

You need to have composer and autloader installed. To be able to install the package, add this entry in the "repositories" index of your composer.json

```
      {
        "type": "vcs",
        "url":  "git@github.com:AliceMajere/wonderland-thread.git"
      }

```

Just require the package with composer

```
composer require alicemajere/wonderland-thread

```

### Usage

[](#usage)

To start a multi-threading Pool, just create a new instance of ThreadPool

```
$threadPool = new ThreadPool();
```

We setup a maximum number of Thread to run at the same time. If we add 200 Threads to the Pool, only 5 of them will run at the same time until the Pool processed all the 200 Threads

```
$threadPool->setMaxRunningThreadNb(5);
```

Add one or more Thread to the Pool by creating a new instance of Thread. A Thread take two parameters, a name and a closure function that will tell the Thread what to do. The closure have to return an exit status from the ones defined in the Thread class constants.

```
$thread = ThreadFactory::create(
    'ThreadName',
    function ($processName) {
        // Implements the Thread processing here
        echo $processName . PHP_EOL;

        // return an exit status at the end of the thread
        return Thread::EXIT_STATUS_SUCCESS;
    }
)

$threadPool->addThread($thread);
```

To run the ThreadPool, you can just do

```
$threadPool->run();

```

You can add Listeners that will trigger on a particular Event while the Pool is running the Threads. Using Listeners can be useful if you need to do particular things for every Threads, like opening a separate mysql connection for every Thread. A Listener object constructor need the Event name to listen to and a closure function that will tell the Listener what to do for this Event. The full list of Event definition is found in the Event class.

```
$threadPool->addListener(new Listener(
    Event::POOL_RUN_START, // Event to trigger the listener
    function (Event $event) use ($website) {
        // Implements the listener
    })
);
$threadPool->addListener(new Listener(
    Event::POOL_RUN_STOP,
    function (Event $event) {
        $this->io->progressFinish();
    })
);
```

Prerequisites
-------------

[](#prerequisites)

PHP &gt;= 7.2

Getting help
------------

[](#getting-help)

If you've instead found a bug in the library or would like new features added, go ahead and open issues or pull requests against this repo!

Authors
-------

[](#authors)

- **Alice Praud** - *Initial work* - [AliceMajere](https://github.com/AliceMajere/wonderland-thread/)

###  Health Score

21

—

LowBetter than 19% of packages

Maintenance0

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity58

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

2763d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/16051792?v=4)[AliceMajere](/maintainers/AliceMajere)[@AliceMajere](https://github.com/AliceMajere)

---

Top Contributors

[![AliceMajere](https://avatars.githubusercontent.com/u/16051792?v=4)](https://github.com/AliceMajere "AliceMajere (20 commits)")

---

Tags

multi-threading-librarythreadthread-pool

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/alicemajere-wonderland-thread/health.svg)

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

###  Alternatives

[soup/paginator

Paginator is a simple class that allows you to create pagination. It doesn't require any database connection. It is compatible with Twitter's Bootstrap Framework, by using the CSS class pagination that is also attached.

351.5k](/packages/soup-paginator)

PHPackages © 2026

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