igoryan-909 / yii2-resque
Queue component for Yii2.
Installs: 195
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 2
Type:yii2-extension
Requires
- php: ^7.0
- yiisoft/yii2: *
- yiisoft/yii2-redis: *
This package is not auto-updated.
Last update: 2024-05-03 18:15:42 UTC
README
Simplified php-resque component for Yii2.
Installation
The preferred way to install this extension is through composer.
Either run
php composer.phar require --prefer-dist igoryan-909/yii2-resque "*"
or add
"igoryan-909/yii2-resque": "*"
to the require section of your composer.json
file.
Usage
Set config :
'controllerMap' => [ 'resque' => [ 'class' => 'ivanoff\resque\controllers\ResqueController', ], ],
Start daemon :
php yii resque/listen queue_name
Add job class :
class MyJob extends Job { public function setUp() { # Set up environment for this job } public function perform() { # The arguments which given in resque enqueue method are available in $this->args } public function tearDown() { # Remove environment for this job } }
For adding job :
$resque = new Resque([ 'redis' => new Connection([ 'hostname' => 'xxx.xxx.xxx.xxx', ]), ]); $token = $resque->enqueue('queue_name', Job::className(), ['arg' => 'val'], true);
For check job status :
$status = (new JobStatus([ 'redis' => new Connection([ 'hostname' => 'xxx.xxx.xxx.xxx', ]), 'id' => $token ]))->get();
or get the status from the resque object with its redis :
$resque->status($token)->get()