2017 © Pedro Peláez
 

library subway

Nuclear reactor powered background job processing for PHP

image

eo/subway

Nuclear reactor powered background job processing for PHP

  • Monday, June 30, 2014
  • by eymengunay
  • Repository
  • 3 Watchers
  • 3 Stars
  • 424 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 7 Versions
  • 0 % Grown

The README.md

Subway

Build Status Scrutinizer Code Quality Code Coverage Total Downloads Latest Stable Version, (*1)

Nuclear reactor powered background job processing for PHP., (*2)

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:, (*3)

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

Now tell composer to download the bundle by running the command:, (*4)

$ php composer.phar update eo/subway

Composer will install everything into your project's vendor directory., (*5)

Usage

Creating job classes

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

<?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., (*7)

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, (*8)

Once you have located the binary or downloaded .phar archive start your worker using the following command:, (*9)

php subway.phar worker

To see all available options and arguments see command help:, (*10)

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, (*11)

The Versions