eo/subway

Nuclear reactor powered background job processing for PHP

Installs: 335

Dependents: 0

Stars: 3

Watchers: 3

Language: PHP

v0.3.0 2014-06-13 20:18 UTC

README

Build Status Scrutinizer Code Quality Code Coverage Total Downloads Latest Stable Version

Nuclear reactor powered background job processing for PHP.

Features

  • Delayed jobs
  • Repeating jobs
  • Resque compatible db
  • Configurable logging
  • Supports composer and symfony based apps out-of-box

Requirements

  • A POSIX-oriented operating system (No windows support due to pcntl dependency)
  • PHP >= 5.4 (with pcntl)
  • Redis

Installation

Add Subway in your composer.json:

{
    "require": {
        "eo/subway": "dev-master"
    }
}

Now tell composer to download the bundle by running the command:

$ php composer.phar update eo/subway

Composer will install everything into your project's vendor directory.

Usage

Creating job classes

To create a new job, extend your job class to Subway\Job and implement abstract method perform.

<?php

use Subway\Job;

class MyAwesomeJob extends Job
{
    public function perform()
    {
        // do something here
    }
}

Queueing jobs

<?php

use Predis\Client;
use Subway\Factory;

$redis  = new Client();
$subway = new Factory($redis);

$message = new Message('default', 'Subway\Tests\Job\Md5Job', array('hello' => 'world'));
$id = $this->factory->enqueue($message);

echo "Job $id enqueued!";

If you need to enqueue Message only once use enqueueOnce method.

Executing jobs

To execute jobs you can either use the binary file distributed with this library (see bin directory) or download the latest .phar archive from: http://eymengunay.github.io/subway/downloads/subway-latest.phar

Once you have located the binary or downloaded .phar archive start your worker using the following command:

php subway.phar worker

To see all available options and arguments see command help:

php subway.phar worker -h

Commands

command description clear Clear subway database help Displays help for a command init Create a new subway configuration file list Lists commands sample Loads sample jobs self-update Updates subway.phar to the latest version status Show subway status worker Starts a subway worker

Reporting an issue or a feature request

Issues and feature requests related to this library are tracked in the Github issue tracker: https://github.com/eymengunay/subway/issues