PHPackages                             zorac/php-resque - 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. [Caching](/categories/caching)
4. /
5. zorac/php-resque

ActiveLibrary[Caching](/categories/caching)

zorac/php-resque
================

Redis backend library for creating background jobs and processing them later. PHP port based on resque for Ruby.

2.13.0(2mo ago)110.4k↓45%1MITPHPPHP ^7.4 || ^8.0

Since Jan 31Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/zorac/php-resque)[ Packagist](https://packagist.org/packages/zorac/php-resque)[ Docs](https://www.github.com/zorac/php-resque/)[ RSS](/packages/zorac-php-resque/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (12)Versions (32)Used By (1)

Resque for PHP
==============

[](#resque-for-php)

[![Software license](https://camo.githubusercontent.com/330884c5a5f4fa6f12d60b485798fb834866b108faee23459eba175d0f5b7420/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f7a6f7261632f7068702d7265737175652e7376673f7374796c653d666c61742d737175617265)](LICENSE)[![PHP version](https://camo.githubusercontent.com/d7ef7d09c841eff6049f719619eb9788c4f2f79c709e69b06eb444bb9698effa/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f7a6f7261632f7068702d7265737175652e7376673f7374796c653d666c61742d737175617265)](https://www.php.net/)[![Latest release](https://camo.githubusercontent.com/b38033802ba9c123ae36fdedb4f7fd755d69a64cb8a5793c02ee7d479aa93490/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7a6f7261632f7068702d7265737175652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/zorac/php-resque)[![Build status](https://camo.githubusercontent.com/f314d7f300510ef1b0bfd378e6c8abb767e16ebc889c436c5c31007e197968a4/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f636f6d2f7a6f7261632f7068702d7265737175652e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.com/zorac/php-resque)

Resque is a Redis-backed library for creating background jobs, placing those jobs on multiple queues, and processing them later.

See also the [change log](CHANGELOG.md) and [upgrade guide](UPGRADING.md).

Background
----------

[](#background)

This version of php-resque is a fork of [php-resque-ex](https://github.com/wa0x6e/php-resque-ex), which is in turn a fork of the original [php-resque](https://github.com/chrisboulton/php-resque)by chrisboulton. See the [original README](https://github.com/chrisboulton/php-resque/blob/master/README.md)for more information.

This fork additionally switches to Predis for the backend, updates to use namespaced code and backports some other features from the lastest [php-resque](https://github.com/resque/php-resque).

NB. Maintaining complete backwards compatability -- other than in respect to the data format in Redis -- is **not** a goal of this fork. Major version upgrades *will* include breaking changes. Support for discontinued version of PHP may be dropped in minor version upgrades.

Additional features
-------------------

[](#additional-features)

This fork provides some additional features:

### Support of Predis

[](#support-of-predis)

This port uses [Predis](https://github.com/nrk/predis) for its backend connection to Redis.

### Powerful logging

[](#powerful-logging)

Instead of piping STDOUT output to a file, you can log directly to a database, or send them elsewhere via a socket. We use [Monolog](https://github.com/Seldaek/monolog)to manage all the logging. See their documentation to see all the available handlers.

Log entries are augmented with more informations, and associated with a worker, a queue, and a job ID if any.

### Job creation delegation

[](#job-creation-delegation)

#### Modern method

[](#modern-method)

Create a class which implements `Resque\Job\CreatorInterface`, and inject it into the worker, e.g.:

```
$worker = new Resque\Worker($queues);
$creator = new My\Creator();
$worker->setCreator($creator);
```

#### Legacy method

[](#legacy-method)

If the `Resque_Job_Creator` class exists and is found by Resque, all jobs creation will be delegated to this class.

The best way to inject this class is to include it in you `APP_INCLUDE` file.

Class content is:

```
class Resque_Job_Creator
{
    /**
     * Create a new Resque Job.
     *
     * @param string $className Your job class name, the second argument when
     *      enqueuing a job.
     * @param array $args The arguments passed to your job.
     */
    public static function createJob($className, $args) {
        return new $className();
    }
}
```

This is pretty useful when your autoloader can not load the class, like when classname doesn't match its filename. Some framework, like CakePHP, uses `PluginName.ClassName` convention for classname, and require special handling before loading.

### Failed jobs logs

[](#failed-jobs-logs)

You can easily retrieve logs for a failed jobs in the redis database, their keys are named after their job ID. Each failed log will expire after 2 weeks to save space.

### Advanced queue filtering

[](#advanced-queue-filtering)

Queue names can include the wildcard character `*`, which will cause the worker to fetch the lsit of all queues, and process all of those which match in a random order. Each `*` matches zero or more characters; you can have multiple wildcards, and specifically a queue name of just `*` whill match all queues. Additionally you can exclude queues by prefixing the name with a `!`; these exclusion patterns may also contain wildcards, and can appear anywhere in the queue list. Exclusions only affect wildcard patterns.

As an example, if the queues are set as follows:

```
QUEUES="system:high,*:high,*,system:low,!*:low"

```

Then the queues will be processed by the worker will be (in order of priority):

1. `system:high`
2. All other queues ending in `:high`, in a random order.
3. All other queues *not* ending in `:low`, in a random order.
4. `system:low`

### Enhanced graceful shutdown

[](#enhanced-graceful-shutdown)

The default graceful shutdown process (triggered by sending a `SIGTERM` to the worker process) waits for `$worker->gracefulDelay` seconds (default five) before forcibly killing the child process with a `SIGKILL`. This will allow short-running jobs to complete whilst still allowing the worker to exit in a reasonable amount of time.

If you want your jobs to be able to gracefully shut themselves down, say to ensure that logging or cleanup is pefrormed even if the job has to be premeturely terminated, then you can set `$worker->gracefulSignal` to the signal you would like to be sent instead of `SIGKILL`. After a further delay of `$worker->gracefulDelayTwo` seconds (default two) a final kill signal will be sent to the child and the worker will exit.

Installation
------------

[](#installation)

The easiest way is using composer, by adding the following to your `composer.json`:

```
    "require": {
        "zorac/php-resque": "^2.0"
    }
```

#### Warning

[](#warning)

php-resque requires the pcntl php extension, not available on Windows platform. Composer installation will fail if you're trying to install this package on Windows machine. If you still want to continue with the installation at your own risk, execute the composer install command with the `--ignore-platform-reqs`option.

Usage
-----

[](#usage)

### Logging

[](#logging)

Use the same way as the original port, with additional ENV :

- `LOGHANDLER`: Specify the handler to use for logging (File, MongoDB, Socket, etc...). See [Monolog](https://github.com/Seldaek/monolog#handlers)doc for all available handlers. `LOGHANDLER` is the name of the handler, without the "Handler" part. To use CubeHandler, just type "Cube".
- `LOGHANDLERTARGET`: Information used by the handler to connect to the database. Depends on the type of loghandler. If it's the *RotatingFileHandler*, the target will be the filename. If it's CubeHandler, target will be a udp address. Refer to each Handler to see what type of argument their `__construct()` method requires.
- `LOGGING`: This environment variable must be set in order to enable logging via Monolog. i.e `LOGGING=1`

If one of these two environement variable is missing, it will default to *RotatingFile* Handler.

### Redis backend

[](#redis-backend)

- `REDIS_BACKEND`: hostname of your Redis database, or Predis DSN
- `REDIS_DATABASE`: To select another redis database (default 0)
- `REDIS_NAMESPACE`: To set a different namespace for the keys (default to *resque*)

Requirements
------------

[](#requirements)

- PHP 7.2+
- Redis 2.2+

Contributors
------------

[](#contributors)

- [chrisboulton](https://github.com/chrisboulton/php-resque) for the original port
- [wa0x6e](https://github.com/wa0x6e/php-resque-ex) for php-resque-ex
- zorac

###  Health Score

55

—

FairBetter than 98% of packages

Maintenance84

Actively maintained with recent releases

Popularity25

Limited adoption so far

Community22

Small or concentrated contributor base

Maturity76

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

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 ~86 days

Recently: every ~272 days

Total

31

Last Release

83d ago

Major Versions

v1.x-dev → 2.8.12020-03-03

2.12.2 → v3.x-dev2023-03-03

PHP version history (6 changes)2.0.0PHP &gt;=5.5.0

2.5.0PHP &gt;=7.1.0

1.2.5PHP &gt;=5.3.0

2.11.0PHP &gt;=7.2.0

v3.x-devPHP ^8.0

2.13.0PHP ^7.4 || ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/2768ebe682a76e86ee591ffccbf100c4f2927c61bce46a955cbf7444585ededa?d=identicon)[zorac](/maintainers/zorac)

---

Top Contributors

[![wa0x6e](https://avatars.githubusercontent.com/u/495709?v=4)](https://github.com/wa0x6e "wa0x6e (107 commits)")[![zorac](https://avatars.githubusercontent.com/u/1845517?v=4)](https://github.com/zorac "zorac (91 commits)")[![chrisboulton](https://avatars.githubusercontent.com/u/98472?v=4)](https://github.com/chrisboulton "chrisboulton (10 commits)")[![mfauveau](https://avatars.githubusercontent.com/u/32339?v=4)](https://github.com/mfauveau "mfauveau (8 commits)")[![hoomanna](https://avatars.githubusercontent.com/u/5413073?v=4)](https://github.com/hoomanna "hoomanna (7 commits)")[![hobodave](https://avatars.githubusercontent.com/u/12404?v=4)](https://github.com/hobodave "hobodave (4 commits)")[![kevburnsjr](https://avatars.githubusercontent.com/u/20638?v=4)](https://github.com/kevburnsjr "kevburnsjr (3 commits)")[![pedroarnal](https://avatars.githubusercontent.com/u/860007?v=4)](https://github.com/pedroarnal "pedroarnal (2 commits)")[![patrickbajao](https://avatars.githubusercontent.com/u/383183?v=4)](https://github.com/patrickbajao "patrickbajao (2 commits)")[![ebernhardson](https://avatars.githubusercontent.com/u/558434?v=4)](https://github.com/ebernhardson "ebernhardson (2 commits)")[![maetl](https://avatars.githubusercontent.com/u/24809?v=4)](https://github.com/maetl "maetl (2 commits)")[![warezthebeef](https://avatars.githubusercontent.com/u/521746?v=4)](https://github.com/warezthebeef "warezthebeef (2 commits)")[![salimane](https://avatars.githubusercontent.com/u/403938?v=4)](https://github.com/salimane "salimane (1 commits)")[![scragg0x](https://avatars.githubusercontent.com/u/222611?v=4)](https://github.com/scragg0x "scragg0x (1 commits)")[![jjfrey](https://avatars.githubusercontent.com/u/799117?v=4)](https://github.com/jjfrey "jjfrey (1 commits)")[![arbet](https://avatars.githubusercontent.com/u/1234119?v=4)](https://github.com/arbet "arbet (1 commits)")[![bpdeployer](https://avatars.githubusercontent.com/u/19269451?v=4)](https://github.com/bpdeployer "bpdeployer (1 commits)")[![brendo](https://avatars.githubusercontent.com/u/69268?v=4)](https://github.com/brendo "brendo (1 commits)")[![d11wtq](https://avatars.githubusercontent.com/u/37948?v=4)](https://github.com/d11wtq "d11wtq (1 commits)")[![danielsmithsd](https://avatars.githubusercontent.com/u/7386446?v=4)](https://github.com/danielsmithsd "danielsmithsd (1 commits)")

---

Tags

phpresquephpredisqueuejobbackgroundresque

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/zorac-php-resque/health.svg)

```
[![Health](https://phpackages.com/badges/zorac-php-resque/health.svg)](https://phpackages.com/packages/zorac-php-resque)
```

###  Alternatives

[mjphaynes/php-resque

Redis backed library for creating background jobs and processing them later.

228199.3k2](/packages/mjphaynes-php-resque)[pdffiller/qless-php

PHP Bindings for qless

29113.2k1](/packages/pdffiller-qless-php)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
