Download the PHP package duckdev/wp-queue-process without Composer

On this page you can find all versions of the php package duckdev/wp-queue-process. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package wp-queue-process

WP Queue Process

WP Queue Process is a WordPress library for firing off non-blocking asynchronous requests and for running long jobs as a background queue. Items pushed onto the queue are worked through in batches that bail out before exhausting the server's time or memory budget, each finished batch chains the next instantly, and a self-healing cron restarts a stalled queue.

📖 Full documentation: docs.duckdev.com/wp-libraries/wp-queue-process/overview

Requirements

Installation

The library autoloads under the DuckDev\Queue\ namespace via PSR-4.

Architecture

Consumers extend one of two abstract classes — Async for a one-off request, Task for a queue. Everything else is a collaborator that Task wires up for you and that you can swap or mock through the constructor. The folder layout mirrors the namespace:

Task delegates persistence to a StoreInterface, load-guarding to ServerLimits, and single-worker locking to ProcessLock. All three are injected through the constructor (with WordPress-backed defaults), so the batch loop can be unit-tested without a database.

Usage

Async Request

Async requests are useful for pushing slow one-off tasks — sending an email, warming a cache — to a background process. Once dispatched, the request processes immediately and out of band.

Extend \DuckDev\Queue\Async:

Dispatch it (chaining is supported):

Background Process

Background processes queue tasks and work through them in batches. Higher-end servers process more items per batch. A health check runs by default every 5 minutes to restart the queue if it ever fails; queues are processed first-in-first-out, so items can be pushed even while one is already running.

Extend \DuckDev\Queue\Task:

Instantiate the process unconditionally (every request, even when nothing is queued), push items, then save and dispatch:

Public methods

Method Description
push_to_queue( $item ) Append a single item to the in-memory queue.
set_queue( array $items ) Replace the in-memory queue wholesale.
save( string $group = 'default' ) Persist the in-memory queue as a new batch.
dispatch() Schedule the health-check cron and start processing.
update( string $key, array $data ) Replace the items of an existing batch.
delete( string $key ) Delete a batch entirely.
cancel_process() Drop the current batch and clear the cron.

Swapping the storage driver

The default OptionStore keeps batches in the (network) options table. Pass your own StoreInterface — or a custom ServerLimits / ProcessLock — to the constructor to change where batches live or how aggressively a batch runs:

Filters

Every filter is namespaced with the process identifier ({prefix}_{action}, e.g. duckdev_example_process):

Filter Default Purpose
{id}_query_args action + nonce Query args added to the dispatch URL.
{id}_query_url admin-ajax.php URL the request is dispatched to.
{id}_post_args non-blocking POST Arguments passed to wp_remote_post().
{id}_default_time_limit 20 Per-batch time budget, in seconds.
{id}_time_exceeded computed Override whether the time budget is spent.
{id}_memory_exceeded computed Override whether the memory budget is spent.
{id}_queue_lock_time 60 Process lock duration, in seconds.
{id}_cron_interval 5 Health-check interval, in minutes.

BasicAuth

If your site is behind BasicAuth, requests rely on the WordPress HTTP API and need credentials attached:

Upgrading from 1.x

The 2.0 release is a structural rewrite. The classes you extend (Async, Task) and their public methods (push_to_queue(), set_queue(), save(), dispatch(), update(), delete(), cancel_process()) and every filter are unchanged, so most consumers only need to bump the requirement.

What changed:

Development

Credits

License

GPLv2+


All versions of wp-queue-process with dependencies

PHP Build Version
Package Version
Requires php Version >=7.4
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package duckdev/wp-queue-process contains the following files

Loading the files please wait ...