PHPackages                             bprs/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. [Queues &amp; Workers](/categories/queues)
4. /
5. bprs/resque

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

bprs/resque
===========

BPRS flavoured port of chrisbolton/php-resque, supports Predis, more DI

2.1.1(11y ago)018MITPHPPHP &gt;=5.3.7

Since Oct 13Pushed 9y agoCompare

[ Source](https://github.com/SrgSteak/php-resque)[ Packagist](https://packagist.org/packages/bprs/resque)[ RSS](/packages/bprs-resque/feed)WikiDiscussions master Synced 2mo ago

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

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

[](#resque-for-php)

About
-----

[](#about)

This is a fork of the vent/resque repo on . The idea is to improve on the package without the need to rely on implementations of vent. It seems the development on the original bundle (chrisboulton/php-resque) and vend stopped a long time ago. The namespacing seems to be a huge improvement over the original implementation. Future updates will include dequeueing and more.

Namespaced Fork
---------------

[](#namespaced-fork)

[![Build Status](https://camo.githubusercontent.com/6ba6b0aef8850c1ba95b92cb8c5bdbd88fad6ea2127d4413053bdbf34797326a/68747470733a2f2f7472617669732d63692e6f72672f76656e642f7068702d7265737175652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/vend/php-resque)[![Latest Stable Version](https://camo.githubusercontent.com/450ab1dd09cf7d8674491270fbba89afd28a473f1221a816b22c3696f9536835/68747470733a2f2f706f7365722e707567782e6f72672f76656e642f7265737175652f762f737461626c652e737667)](https://packagist.org/packages/vend/resque)[![Latest Unstable Version](https://camo.githubusercontent.com/83a8836beaae9ac08dabbd1bdd8a85e9a203ffac600d55dd2d9a8bca41ae4a1e/68747470733a2f2f706f7365722e707567782e6f72672f76656e642f7265737175652f762f756e737461626c652e737667)](https://packagist.org/packages/vend/resque)[![License](https://camo.githubusercontent.com/f7b493797db9f2e09b10067315c1fb5e9e3855ea2b03d5b37e06ab2dd678eb9d/68747470733a2f2f706f7365722e707567782e6f72672f76656e642f7265737175652f6c6963656e73652e737667)](https://packagist.org/packages/vend/resque)

[Resque](https://github.com/resque/resque) is a Redis-backed library for creating background jobs, placing those jobs on one or more queues, and processing them later.

This is a PHP fork of the Resque worker and job classes. This makes it compatible with the resque-web interface, and with other Resque libraries. (You could enqueue jobs from Ruby and dequeue them in PHP, for instance).

This library (`vend/resque`) is a fork of [chrisboulton/php-resque](https://github.com/chrisboulton/php-resque) at around version 1.3, that has been refactored to remove global state, add namespacing, and improve decoupling. This makes it easier to use and extend.

Getting Started
---------------

[](#getting-started)

Add `vend/resque` to your application's composer.json.

```
{
    "require": {
        "vend/resque": "~2.1.0"
    }
}
```

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

[](#requirements)

- PHP 5.3+
- A Redis client library (for instance, [Predis](https://github.com/nrk/predis) or [Credis](https://github.com/colinmollenhour/credis))

Jobs
----

[](#jobs)

### Queueing Jobs

[](#queueing-jobs)

Jobs are queued as follows:

```
use Resque\Resque;
use Predis\Client;

$resque = new Resque(new Client());
$resque->enqueue('default_queue', 'App\Job', array('foo' => 'bar'), true);
```

In order the arguments are: queue, job class, job payload, whether to enable tracking.

### Defining Jobs

[](#defining-jobs)

Each job should be in its own class, and implement the `Resque\JobInterface`. (This is pretty easy, and only really requires a single custom method: `perform()`.) Most of the time, you'll want to use the default implementation of a Job, and extend the `Resque\AbstractJob` instead of implementing the interface yourself:

```
namespace App;

use Resque\AbstractJob;

class Job extends AbstractJob
{
    public function perform()
    {
        // work work work
        $this->doSomething($this->payload['foo']);
    }
}
```

Any exception thrown by a job will result in the job failing - be careful here and make sure you handle the exceptions that shouldn't result in a job failing.

### Job Status Tracking

[](#job-status-tracking)

vend/resque has the ability to perform basic status tracking of a queued job. The status information will allow you to check if a job is in the queue, is currently being run, has finished, or has failed.

To track the status of a job, pass `true` as the fourth argument to `Resque\Resque::enqueue`. An ID used for tracking the job status will be returned:

```
$id = $resque->enqueue('default_queue', 'App\Job', $payload, true);
echo $id; // [0-9a-f]{32}
```

To fetch the status of a job:

```
$factory = new Resque\Job\StatusFactory($resque);

// Pass the ID returned from enqueue
$status = $factory->forId($id);

// Alternatively, to get the status for a Job instance:
$status = $factory->forJob($job);

// Outputs the status as a string: 'waiting', 'running', 'complete', etc.
echo $status->getStatus();
```

The Status object contains methods for adding other attributes to the tracked status. (For instance, you might use the status object to track errors, completion information, iterations, etc.)

#### Statuses

[](#statuses)

Job statuses are defined as constants in the `Resque\Job\Status` class. Valid statuses include:

- `Resque\Job\Status::STATUS_WAITING` - Job is still queued
- `Resque\Job\Status::STATUS_RUNNING` - Job is currently running
- `Resque\Job\Status::STATUS_FAILED` - Job has failed
- `Resque\Job\Status::STATUS_COMPLETE` - Job is complete

Statuses are available for up to 24 hours after a job has completed or failed, and are then automatically expired. A status can also forcefully be expired by calling the `stop()` method on a status class.

Console
-------

[](#console)

You are free you implement your own daemonization/worker pool strategy by subclassing the `Worker` class. For playing around, and low throughput applications, you might like to use the built-in console commands.

This version of the library uses the Symfony2 Console component. But it must be configured with the details of your Redis connection. We do this in much the same way that the Doctrine2 Console component gets details of your database connection: via a `cli-config.php` file.

There is an example `cli-config.php` in this repository.

If you're running a full-stack web application, you'd generally use your locator/service container to fill in the Redis client connection in this file. (The default is to use Predis, and to connect to 127.0.0.1:6379).

### Basic Usage

[](#basic-usage)

```
resque

Available commands:
  enqueue       Enqueues a job into a queue
  help          Displays help for a command
  list          Lists commands
  worker        Runs a Resque worker
queue
  queue:clear   Clears a specified queue
  queue:list    Outputs information about queues

```

### Enqueueing

[](#enqueueing)

This command will enqueue a `Some\Test\Job` job onto the `default` queue. Watch out for the single quotes around the class name: when specifying backslashes on the command line, you'll probably have to avoid your shell escaping them.

```
resque enqueue default 'Some\Test\Job' -t

```

### Worker

[](#worker)

This command will run a simple pre-forking worker on two queues:

```
resque worker -Q default -Q some_other_queue

```

(`-q` means quiet, `-Q` specifies queues). You can also specify no queues, or the special queue `'*'` (watch for shell expansion).

### Queue Information

[](#queue-information)

There are a couple of useful commands for getting information about the queues. This will show a list of queues and how many jobs are waiting on each:

```
resque queue:list

```

This command will clear a specified queue:

```
resque queue:clear default

```

### Logging

[](#logging)

The library now uses PSR3. When running as a console component, you can customise the logger to use in `cli-config.php`. (For instance, you might like to send your worker logs to Monolog.)

Why Fork?
---------

[](#why-fork)

Unfortunately, several things about the existing versions of php-resque made it a candidate for refactoring:

- php-resque supported the Credis connection library and had hard-coded this support by using static accessors. This meant more advanced features such as replication and pipelining were unavailable.
    - Now, Resque for PHP supports any client object that implements a suitable subset of Redis commands. No type-checking is done on the passed in connection, meaning you're free to use Predis, or whatever you like.
- While the public API of `php-resque` was alright, the protected API was pretty much useless. This made it hard to extend worker classes to dispatch jobs differently.
- Important state (the underlying connection) was thrown into the global scope by hiding it behind static accessors (`Resque::redis()`). This makes things easier for the library author (because he/she need not think about dependencies) but also statically ties together the classes in the library: it makes testing and extending the library hard.
    - There's no reason to do this: `Resque` instances should simply use DI and take a client connection as a required constructor argument.
    - This improvement also allows the connection to be mocked without extending the `Resque` class.
    - And it lets you reuse your existing connection to Redis, if you have one. No need to open a new connection just to enqueue a job.
- Statistic classes were static for no good reason.
    - To work, statistics need a connection to Redis, a name, and several methods (get, set). State and methods to manipulate it? Sounds like a task for objects! *Not* just static methods, that don't encapsulate any of the state.
    - Because these were static calls, the `Resque_Stat` class was hard-coded into several other classes, and could not be easily extended.
- The library is now fully namespaced and compatible with PSR-0. The top level namespace is `Resque`.
- The events system has been removed. There is now little need for it. It seems like the events system was just a workaround due to the poor extensibility of the Worker class. The library should allow you to extend any class you like, and no method should be too long or arduous to move into a subclass.

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

[](#contributors)

Here's the contributor list from earlier versions, at [chrisboulton/php-resque](https://github.com/chrisboulton/php-resque):

- @chrisboulton
- @acinader
- @ajbonner
- @andrewjshults
- @atorres757
- @benjisg
- @cballou
- @chaitanyakuber
- @charly22
- @CyrilMazur
- @d11wtq
- @danhunsaker
- @dceballos
- @ebernhardson
- @hlegius
- @hobodave
- @humancopy
- @JesseObrien
- @jjfrey
- @jmathai
- @joshhawthorne
- @KevBurnsJr
- @lboynton
- @maetl
- @matteosister
- @MattHeath
- @mickhrmweb
- @Olden
- @patrickbajao
- @pedroarnal
- @ptrofimov
- @rajibahmed
- @richardkmiller
- @Rockstar04
- @ruudk
- @salimane
- @scragg0x
- @scraton
- @thedotedge
- @tonypiper
- @trimbletodd
- @warezthebeef

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor5

5 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 ~106 days

Recently: every ~21 days

Total

9

Last Release

4109d ago

Major Versions

1.2 → 2.0.12013-09-30

PHP version history (2 changes)1.2PHP &gt;=5.3.0

2.1.0-alphaPHP &gt;=5.3.7

### Community

Maintainers

![](https://www.gravatar.com/avatar/8308048b9a592599fa611b4b41964382146ee4b5f309fed00aa214ffff6ab5b3?d=identicon)[SrgSteak](/maintainers/SrgSteak)

---

Top Contributors

[![dominics](https://avatars.githubusercontent.com/u/97427?v=4)](https://github.com/dominics "dominics (6 commits)")[![SrgSteak](https://avatars.githubusercontent.com/u/8882558?v=4)](https://github.com/SrgSteak "SrgSteak (4 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)")[![warezthebeef](https://avatars.githubusercontent.com/u/521746?v=4)](https://github.com/warezthebeef "warezthebeef (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)")[![patrickbajao](https://avatars.githubusercontent.com/u/383183?v=4)](https://github.com/patrickbajao "patrickbajao (2 commits)")[![pedroarnal](https://avatars.githubusercontent.com/u/860007?v=4)](https://github.com/pedroarnal "pedroarnal (2 commits)")[![teake](https://avatars.githubusercontent.com/u/1324716?v=4)](https://github.com/teake "teake (2 commits)")[![bpdeployer](https://avatars.githubusercontent.com/u/19269451?v=4)](https://github.com/bpdeployer "bpdeployer (1 commits)")[![andrewjshults](https://avatars.githubusercontent.com/u/175454?v=4)](https://github.com/andrewjshults "andrewjshults (1 commits)")[![salimane](https://avatars.githubusercontent.com/u/403938?v=4)](https://github.com/salimane "salimane (1 commits)")[![dceballos](https://avatars.githubusercontent.com/u/131104?v=4)](https://github.com/dceballos "dceballos (1 commits)")[![jmathai](https://avatars.githubusercontent.com/u/6384?v=4)](https://github.com/jmathai "jmathai (1 commits)")[![d11wtq](https://avatars.githubusercontent.com/u/37948?v=4)](https://github.com/d11wtq "d11wtq (1 commits)")[![scrutinizer-auto-fixer](https://avatars.githubusercontent.com/u/6253494?v=4)](https://github.com/scrutinizer-auto-fixer "scrutinizer-auto-fixer (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[symfony/messenger

Helps applications send and receive messages to/from other applications or via message queues

1.1k120.7M958](/packages/symfony-messenger)[php-amqplib/rabbitmq-bundle

Integrates php-amqplib with Symfony &amp; RabbitMq. Formerly emag-tech-labs/rabbitmq-bundle, oldsound/rabbitmq-bundle.

1.3k20.1M65](/packages/php-amqplib-rabbitmq-bundle)[league/geotools

Geo-related tools PHP 7.3+ library

1.4k5.3M26](/packages/league-geotools)[symfony/amazon-sqs-messenger

Symfony Amazon SQS extension Messenger Bridge

4612.5M15](/packages/symfony-amazon-sqs-messenger)[toin0u/geotools

Geo-related tools PHP 7.3+ library

1.4k1.3k](/packages/toin0u-geotools)[orisai/scheduler

Cron job scheduler - with locks, parallelism and more

4037.1k4](/packages/orisai-scheduler)

PHPackages © 2026

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