yiicod / laravel5queue
Installs: 39
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 2
Forks: 0
Open Issues: 1
Type:yii-extension
Requires
- illuminate/encryption: ^5.2
- illuminate/queue: 5.2.*
- jeremeamia/superclosure: ^2.0
- paragonie/random_compat: ^1.2
- sammaye/mongoyii-php7: *
- symfony/process: ~2.3|~3.0
This package is not auto-updated.
Last update: 2022-02-01 12:57:49 UTC
README
Branch 1.0 for php 5.6 Branch master for php 7.0
First of all add laravel5queue component to Yii config (console and main) like this:
'preload' => ['laravel5queue'], 'components' => ['laravel5queue' => ['class' => 'yiicod\laravel5queue\Laravel5Queue']]
and console command like this:
'queueWorker' => ['class' => 'yiicod\laravel5queue\commands\WorkerCommand'],
also: component requires "mongodb" component to connect mongo database
Adding jobs to queue:
- For callable functions:
yiicod\laravel5queue\Laravel5Queue::push(function($job) { <--YOUR CODE HERE--> });
Note: you have to call $job->delete(); in the end of your function to remove it from database
- For handlers:
Create your own handler which implements yiicod\laravel5queue\base\BaseHandlerInterface OR extends yiicod\laravel5queue\handlers\Handler and run parent::fire($job, $data) to restart db connection before job
yiicod\laravel5queue\Laravel5Queue::push(<--YOUR HANDLER CLASS NAME->>, $data);
Note: $data - additional data to your handler
Start worker:
run worker daemon with console command like this:
$ php yiic queueWorker start
stop worker daemon:
$ php yiic queueWorker stop