Download the PHP package jenwachter/php-redis-queue without Composer

On this page you can find all versions of the php package jenwachter/php-redis-queue. 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 php-redis-queue

PHP Redis Queue

A simple background server queue utilizing Redis and PHP.

Requirements

Installation

To install the library, you will need to use Composer in your project.

How it works

A worker defines a queue, listens for jobs to get pushed into the queue, and performs work to complete each job in the queue. A single queue can handle multiple types of jobs, specified by different callbacks. For example, you can create a queue to handle file uploads that can both upload and delete files using upload and delete callbacks. Ideally, workers are run as a process on a server.

A client pushes jobs into a queue, optionally with data needed by the worker to complete the job. For example, for a job that uploads files, passing the path of the file would be helpful.

When a client pushes a job into a queue, it waits in the queue until it reaches the top. Once it does, the worker:

  1. Removes the job from the queue and adds it to a processing queue.
  2. Determines if there is an available callback for this job. If there isn't, the job is considered failed.
  3. Calls a before callback for the job type, if defined.
  4. Calls the main callback for the job type.
    1. If the callback does not throw an exception, it is considered successful. If the callback throws an exception, it is considered failed.
    2. The job is removed from the processing queue and added to either the failed or success list.
  5. Calls an after callback for the job type, if defined.
  6. If the job is part of a job group and all jobs within the group have completed, the worker calls the group_after callback, if defined.
  7. The queue moves on to the next job or waits until another is added.

Quick example

In this quick example, we'll set up a worker that handles processing that needs to be done when uploading and deleting files. We'll then create a client to send jobs to the worker.

Create a worker

If using the default settings of the work() method (blocking), only one worker (queue) can be run in a single file; however, a single worker can handle multiple types of jobs. For example, here we create the files worker that can handle processing that needs to be done when both a file is uploaded and deleted:

files.php

Run the worker

To run the worker, you can run it manually on a server:

But once the script exits or the connection closes, the worker will also stop running. This is helpful for testing during development, but not so much in a production environment.

To ensure your worker is always running, run the worker as a process using a system such as Supervisor.

Create a client

Continuing with our files example, the following client code would be executed after a file is uploaded or deleted in the system.

Job groups

You can also group jobs into a Job Group, which enables you to use the group_after callback when all jobs in the group have completed. Jobs added to a job group can be assigned to any queue. Refer to the Job Group documentation for more details.

client.php

worker.php

Documentation

Worker

Initialization

Note: queuename cannot be an integer.

Configuration

Some parts of the worker can be customized by sending an array of options as the third argument.

Available options:

Methods

addCallback(string $name, callable $callable)

Attaches a callback to the worker. Available callbacks:

Returns: Null.

Arguments:

work(bool $block = true)

Instructs the worker to begin listening to the queue.

Returns: Null.

Arguments:

Client

Initialization

Configuration

Some parts of the worker can be customized by sending an array of options as the second argument.

Available options:

Methods

push(string $queue, string $jobName = 'default', array $jobData = [])

Pushes a job to the end of a queue.

Returns: Integer. ID of job.

Arguments:

pushToFront(string $queue, string string $jobName = 'default', array $jobData = [])

Pushes a job to the front of a queue.

Returns: Integer. ID of job.

Arguments:

pull(int $id)

Pull a job from a queue.

Returns: Boolean. true if the job was successfully removed; otherwise, false.

Arguments:

rerun(int $id)

Reruns a previously failed job. Throws an exception if the job was successful already or cannot be found.

Returns: Boolean. TRUE if the job was successfully readded to the queue.

Arguments:

createJobGroup(int total = null, $data = [])

Creates a job group, which allows you to link jobs together. Use the group_after callback to perform work when all jobs in the group have completed.

Returns: PhpRedisQueue\models\JobGroup object

Arguments:

Job Group

Initialization

A job group are created via the Client::createJobGroup, which then returns the JobGroup model.

Returns: JobGroup model

Arguments:

JobGroup Model Methods

push(string $queue, string $jobName = 'default', array $jobData = [])

Pushes a job to the job group. Note: jobs cannot be added to a Job Group if it has already been queued.

Returns: Integer. ID of job.

Arguments:

setTotal(int total)

Tells the group how many jobs to expect. Enables the Job Group to automatically add the jobs to the queue once the total is reached. Alternatively, use JobGroup::queue() to manually queue.

Returns: Boolean. TRUE if the total was successfully set.

queue()

Add the group's jobs to the queue. Only use this method if the Job Group is unaware of the total number of jos to expect via initialization of JobGroup::setTotal().

Returns: Boolean

removeFromQueue()

Removes any remaining jobs in the group from their queues.

Returns: Boolean

getJobs()

Get an array of jobs associated with the group.

Returns: array of Job models.

getUserData()

Get the data assigned to the group on initialization.

Returns: array

CLI

The command line interface allows you to interact with the queue. To access the tool, run:

To list all available commands, run:

To get help with a command, run:

Get help with a command


All versions of php-redis-queue with dependencies

PHP Build Version
Package Version
Requires php Version >=8.0
composer-runtime-api Version ^2.2
predis/predis Version ^2.1
psr/log Version ^1|^2|^3
symfony/console Version ^4|^5|^6
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 jenwachter/php-redis-queue contains the following files

Loading the files please wait ....