Nuclear reactor powered background job processing for PHP.
- Delayed jobs
- Repeating jobs
- Resque compatible db
- Configurable logging
- Supports composer and symfony based apps out-of-box
- A POSIX-oriented operating system (No windows support due to pcntl dependency)
- PHP >= 5.4 (with pcntl)
- Redis
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.
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
}
}
<?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.
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
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 |
Issues and feature requests related to this library are tracked in the Github issue tracker: https://github.com/eymengunay/subway/issues