eo / subway
Nuclear reactor powered background job processing for PHP
Requires
- php: >=5.4.0
- doctrine/collections: ~1.0
- herrera-io/phar-update: ~2.0
- monolog/monolog: ~1.7
- predis/predis: ~0.8
- react/event-loop: ~0.4
- symfony/config: ~2.3
- symfony/console: ~2.3
- symfony/event-dispatcher: ~2.3
- symfony/options-resolver: ~2.3
Requires (Dev)
- phpunit/phpunit: 3.7.*
README
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
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