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

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

a5hleyrich/wp-queue
===================

WordPress job queues

2.2.0(2mo ago)18021.5k↓35.7%41[3 issues](https://github.com/A5hleyRich/wp-queue/issues)1MITPHPPHP ^7.3|^8.0

Since Oct 6Pushed 2mo ago12 watchersCompare

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

READMEChangelog (10)Dependencies (12)Versions (13)Used By (1)

WP Queue
========

[](#wp-queue)

[![Total Downloads](https://camo.githubusercontent.com/dad485f3b8a24f127e80b35b41ea8d7e5c8ec0e2576ba8ccf97b8cad00043087/68747470733a2f2f706f7365722e707567782e6f72672f64656c6963696f7573627261696e732f77702d71756575652f646f776e6c6f616473)](https://packagist.org/packages/deliciousbrains/wp-queue)[![Latest Stable Version](https://camo.githubusercontent.com/c89a84a4961f5de490c523d4acd3289027e9d21d0fa7748955a631162c05ecb6/68747470733a2f2f706f7365722e707567782e6f72672f64656c6963696f7573627261696e732f77702d71756575652f762f737461626c65)](https://packagist.org/packages/deliciousbrains/wp-queue)[![License](https://camo.githubusercontent.com/cbf7dd200ee319596437dd99bf2506862b2202e795bb452356d2cdc974c6342f/68747470733a2f2f706f7365722e707567782e6f72672f64656c6963696f7573627261696e732f77702d71756575652f6c6963656e7365)](https://packagist.org/packages/deliciousbrains/wp-queue)

Job queues for WordPress.

Install
-------

[](#install)

The recommended way to install this library in your project is by loading it through Composer:

```
composer require deliciousbrains/wp-queue
```

It is highly recommended to prefix wrap the library class files using [PHP-Scoper](https://packagist.org/packages/humbug/php-scoper), to prevent collisions with other projects using this same library.

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

[](#prerequisites)

WP\_Queue requires PHP **7.3+**.

The following database tables need to be created:

```
CREATE TABLE {$wpdb->prefix}queue_jobs (
    id bigint(20) NOT NULL AUTO_INCREMENT,
    job longtext NOT NULL,
    attempts tinyint(3) NOT NULL DEFAULT 0,
    reserved_at datetime DEFAULT NULL,
    available_at datetime NOT NULL,
    created_at datetime NOT NULL,
    PRIMARY KEY (id)
);
```

```
CREATE TABLE {$wpdb->prefix}queue_failures (
    id bigint(20) NOT NULL AUTO_INCREMENT,
    job longtext NOT NULL,
    error text DEFAULT NULL,
    failed_at datetime NOT NULL,
    PRIMARY KEY (id)
);
```

Alternatively, you can call the `wp_queue_install_tables()` helper function to install the tables. If using WP\_Queue in a plugin you may opt to call the helper from within your `register_activation_hook`.

Jobs
----

[](#jobs)

Job classes should extend the `WP_Queue\Job` class and normally only contain a `handle` method which is called when the job is processed by the queue worker. Any data required by the job should be passed to the constructor and assigned to a public property. This data will remain available once the job is retrieved from the queue. Let's look at an example job class:

```
