• This repository has been archived on 23/Mar/2023
  • Stars
    star
    137
  • Rank 257,789 (Top 6 %)
  • Language
    PHP
  • License
    MIT License
  • Created about 12 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

PHP port of resque (Workers and Queueing), with phpredis support, and more logging options

Php-Resque-ex: Resque for PHP Build Status

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

Background

Php-Resque-Ex is a fork of php-resque by chrisboulton. See the original README for more informations.

Additional features

This fork provides some additional features :

Support of php-redis

Autodetect and use phpredis to connect to Redis if available. Redisent is used as fallback.

Powerfull 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 to manage all the logging. See their documentation to see all the available handlers.

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

Job creation delegation

If 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
{
	public static function createJob($className, $args) {

		// $className is you job class name, the second arguments when enqueuing a job
		// $args are the arguments passed to your jobs

		// Instanciate your class, and return the instance

		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

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.

Command Line tool

Fresque is shipped by default to manage your workers. See Fresque Documentation for usage.

Installation

Clone the git repo

$ git clone git://github.com/wa0x6e/php-resque-ex.git

cd into the folder you just cloned

$ cd ./php-resque-ex

Download Composer

$ curl -s https://getcomposer.org/installer | php

Install dependencies

$ php composer.phar install

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

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 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 : hostname of your Redis database
  • REDIS_DATABASE : To select another redis database (default 0)
  • REDIS_NAMESPACE : To set a different namespace for the keys (default to resque)
  • REDIS_PASSWORD : If your Redis backend needs authentication

Requirements

  • PHP 5.3+
  • Redis 2.2+

Contributors

More Repositories

1

cal-heatmap

Cal-Heatmap is a javascript charting library to create a time-series calendar heatmap
TypeScript
2,534
star
2

Cake-Resque

Resque plugin for CakePHP : for creating background jobs that can be processed offline later
PHP
159
star
3

ResqueBoard

ResqueBoard is an analytics software for PHP Resque. Monitor your workers health and job activities in realtime
CSS
145
star
4

Fresque

A command line tool to manage your php-resque workers
PHP
128
star
5

php-resque-ex-scheduler

An addon for php-resque that lets you queue jobs for execution some time in the future. Follows resque-scheduler.
PHP
26
star
6

dashing-resque

Resque dashing widget to monitor resque jobs, queues and worker activities.
CoffeeScript
23
star
7

CakePHP-Memcached-Engine

Memcached storage engine for CakePHP, using the memcached extension
PHP
21
star
8

DebugKitEx

An extension for CakePHP DebugKit plugin
PHP
16
star
9

cakephp-predictionio

CakePHP Plugin for the PredictionIO machine learning server
PHP
10
star
10

ResqueStatus

ResqueStatus is an API to save a php-resque worker settings in Redis. It's used by CakeResque, Fresque and ResqueBoard to restart, stop, pause and resume workers.
PHP
6
star
11

cal-heatmap-react-starter

A React demo using cal-heatmap
CSS
5
star
12

bounce

A very lightweight CakePhp plugin to make your models automagically indexable by Elastic Search
PHP
4
star
13

CakePHP-NoSQL-Datasource

A low-lever interface to interact with nosql datasource for CakePHP
PHP
4
star
14

cal-heatmap-doc

Cal-Heatmap documentation website
HTML
1
star
15

cal-heatmap-vue-starter

A VueJS demo using cal-heatmap
Vue
1
star