PHPackages                             morningtrain/wp-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. morningtrain/wp-queue

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

morningtrain/wp-queue
=====================

Create Queue system for WP

v0.4.0(2y ago)21.7k[2 issues](https://github.com/Morning-Train/wp-queue/issues)MITPHP

Since Jan 11Pushed 2y ago3 watchersCompare

[ Source](https://github.com/Morning-Train/wp-queue)[ Packagist](https://packagist.org/packages/morningtrain/wp-queue)[ RSS](/packages/morningtrain-wp-queue/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (1)Versions (6)Used By (0)

Morningtrain\\WP\\Queue
=======================

[](#morningtrainwpqueue)

Queue system for WordPress.

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

[](#table-of-contents)

- [Introduction](#introduction)
- [Getting Started](#getting-started)
    - [Installation](#installation)
- [Usage](#usage)
    - [Register Worker](#register-worker)
    - [Create a Job](#create-a-job)
    - [Running the Queue Worker](#running-the-queue-worker)
- [Credits](#credits)
- [License](#license)

Introduction
------------

[](#introduction)

This package is made to dispatch jobs to a queue system.

It is implementet with WP CLI so it can be runned from the command line.

Getting started
---------------

[](#getting-started)

To get started install the package as described below in [Installation](#installation).

To use the package have a look at [Usage](#usage)

### Installation

[](#installation)

Install with composer.

`composer require morningtrain/wp-queue`

Usage
-----

[](#usage)

### Register Worker

[](#register-worker)

To get started with the module simply register a job queue `\Morningtrain\WP\Queue\Queue::registerWorker()`.

You can change name of the job queue from default `job_queue`. You can change the version of the job queue database table from default `1.0.0`.

```
\Morningtrain\WP\Queue\Queue::registerWorker();
```

### Create a Job

[](#create-a-job)

Jobs can be created by extending `Morningtrain\WP\Queue\Abstracts\AbstractJob` and create a `handle` method.

You can define which job\_queue the job should use by setting the `$worker` parameter to the job queue slug.

Now you can put a job in the queue by calling the static method `dispatch` on your Job class.

```
// Job/TestJob.php
use Morningtrain\WP\Queue\Abstracts\AbstractJob;

class TestJob extends AbstractJob {

  public static function handle(mixed $args) : mixed
  {
    // Do something
    return 'testing...';
  }
}
```

```
// Another file
TestJob::dispatch('test_arg');
```

#### Alternatively Job Creation

[](#alternatively-job-creation)

Jobs can alternativley be created directly from the worker, by passing a callback to the `createJob` method.

```
\Morningtrain\WP\Queue\Classes\Worker::getWorker('job_queue')->createJob($callback, $args);
```

#### Arguments

[](#arguments)

If you use arguments in your jobs, you have to be aware, that we are using `call_user_func_array`. So if you pass an array, you need to have same number of arguments in your method as you have in your array. And if keyed, the arguments in the method must be called the same as the keys.

If you do not know the number of arguments in your array or you just need to work on an data array, you can use `...$args` in your method. Or you can wrap your array in an extra array containing only the one argument.

See more about `call_user_func_arrey` on the [PHP documentation](https://www.php.net/manual/en/function.call-user-func-array.php)

### Running the Queue Worker

[](#running-the-queue-worker)

Use WP CLI to run the job queue. See [WP CLI documentation](https://wp-cli.org/).

#### Start Worker

[](#start-worker)

Start job queue with the `wp queue start` command and the worker slug.

```
wp queue start job_queue

```

> **Note**
>
> The worker will run until it is manually stopped or the terminal is closed. You should use a process monitor such as [Supervisor](http://supervisord.org/index.html) to make sure the process does not stop unintended.

You can run multiple workers simultaneously.

#### Stop Worker

[](#stop-worker)

To stop a worker that you can not stop by closing you terminal, you can use the `stop` command with the worker slug.

```
wp queue stop job_queue

```

To stop all workers use `all` instead of worker slug.

```
wp queue stop all

```

#### List available workers

[](#list-available-workers)

To list available workers and their status, use the `list` command

```
wp queue list

```

#### Process a Specific Job

[](#process-a-specific-job)

Call `wp queue run` with the worker slug and the job ID to process the specific job.

```
wp queue run job_queue 99

```

> **Note**
>
> You can use --untouched to not set run\_date and result `wp queue run jon_queue 99 --untouched`
>
> You can use --force to force the job to run even though it has run before `wp queue run jon_queue 99 --force`

Credits
-------

[](#credits)

- [Martin Schadegg Brønniche](https://github.com/mschadegg)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance0

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity39

Early-stage or recently created project

 Bus Factor1

Top contributor holds 83.3% 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 ~44 days

Total

5

Last Release

1047d ago

### Community

Maintainers

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

---

Top Contributors

[![mschadegg](https://avatars.githubusercontent.com/u/11231039?v=4)](https://github.com/mschadegg "mschadegg (20 commits)")[![matbaek](https://avatars.githubusercontent.com/u/2310644?v=4)](https://github.com/matbaek "matbaek (2 commits)")[![larasmorningtrain](https://avatars.githubusercontent.com/u/86046759?v=4)](https://github.com/larasmorningtrain "larasmorningtrain (1 commits)")[![mrmoeg](https://avatars.githubusercontent.com/u/5990117?v=4)](https://github.com/mrmoeg "mrmoeg (1 commits)")

---

Tags

job-queuequeuequeue-workerswordpresswp

### Embed Badge

![Health badge](/badges/morningtrain-wp-queue/health.svg)

```
[![Health](https://phpackages.com/badges/morningtrain-wp-queue/health.svg)](https://phpackages.com/packages/morningtrain-wp-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)
