PHPackages                             kwhat/legume - 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. kwhat/legume

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

kwhat/legume
============

Legume: Multi-thread Job Manager and Daemon

15[1 issues](https://github.com/kwhat/legume/issues)PHP

Since Nov 25Pushed 6y ago1 watchersCompare

[ Source](https://github.com/kwhat/legume)[ Packagist](https://packagist.org/packages/kwhat/legume)[ RSS](/packages/kwhat-legume/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependenciesVersions (1)Used By (0)

Legume: Multi-thread Job Manager and Daemon
===========================================

[](#legume-multi-thread-job-manager-and-daemon)

Creating and managing a pool of workers for parallel processing can be a challenging endeavor. Fortunately, Legume provides a lightweight php-pthread implementation capable of connecting to different queues. Currently only beanstalkd is supported, however RabbitMQ support will be added in the future. The legume job manager is capable of scaling the number of running workers based on queue demand and will only take jobs it has capacity to process. Legume also supports high concurrency with low overhead. The only limiting factor will be the load of the jobs themselves.

Usage
-----

[](#usage)

This project has two usage paths, one for running the daemon, and one for creating and queueing jobs.

### Daemon Control

[](#daemon-control)

The daemon manager can be accessed via `./bin/legumed --help`.

```
 # bin/legumed -H
   Usage: bin/legumed  [options] [operands]

   Options:
     -H, --help
     -P, --pid
     -v, --verbose

   Commands:
     start    Start the worker
     stop     Stop the worker

```

To start the daemon, simply call `./bin/legumed start`. If you would like to start a background process, add the `-D, --daemon` flag. To stop the daemon, run `./bin/legumed stop`. If you started the daemon without `-D, --daemon`, SIGTERM or SIGINT will halt the foreground process. Please note, if you are trying to start the daemon and receive an exception regarding changing the pool's user, group or priority, you need to start `./bin/legumed` with privileges using the root user or sudo command.

Job Configuration
-----------------

[](#job-configuration)

Available jobs are configured via [conf/legumed.conf.php](conf/legumed.conf.php). This file contains an associative array of job names mapped to a [callable](http://php.net/manual/en/language.types.callable.php) or classname string implementing the [JobHandlerInterface](src/JobHandlerInterface.php). All valid classes will be registered with all workers in the pool, any invalid class will be ignored.

### Creating Jobs

[](#creating-jobs)

To create a Legume job, simply implement the [Legume\\Job\\HandlerInterface](src/Job/HandlerInterface.php) in your class and add the full namespace to the job configuration file. When a job is picked up by the worker, the `__invoke($jobId, $workload)` method will be called with the current job id and the workload used when queueing the job. No processing such as `unserialze()` or `json_decode()` will be applied to the workload.

### Queueing Job Workloads

[](#queueing-job-workloads)

Legume does not provide any direct job queueing functionality. Instead, the library used to communicate with the intended job queue should be used. The job name provided to the client must match a configured with one or more legume instances using the `start` command with the `--jobs` flag.

```
$client = new Pheanstalk("127.0.0.1");

$seconds = rand(15, 60 * 1);

$client->useTube("ExampleJob")
    ->put($seconds, Pheanstalk::DEFAULT_PRIORITY, Pheanstalk::DEFAULT_DELAY, Pheanstalk::DEFAULT_TTR);

```

Additional Information
----------------------

[](#additional-information)

Up to date source code and documentation available at:

###  Health Score

13

—

LowBetter than 1% of packages

Maintenance0

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity35

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/b4908b429b924b015ba7068223413a26bff2ccbe7fdac117662481bd88e20059?d=identicon)[kwhat](/maintainers/kwhat)

---

Top Contributors

[![kwhat](https://avatars.githubusercontent.com/u/676164?v=4)](https://github.com/kwhat "kwhat (12 commits)")

### Embed Badge

![Health badge](/badges/kwhat-legume/health.svg)

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

###  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)
