levmv / mii-queue
Mii queue extension
Installs: 1 102
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 0
Requires
- php: >=7.4
- ext-pcntl: *
- levmv/mii: ^1.9
This package is auto-updated.
Last update: 2024-11-07 17:06:52 UTC
README
Inspired by yii2-queue
Installation
composer require levmorozov/mii-queue
Basic Usage
Each task which is sent to queue should be defined as a separate class.
class EmailJob extends Job { public $to; public $body; public function execute($queue) { Mii::$app->mailer()->to($this->to)->body($body)->send(); } }
Here's how to send a task into the queue:
Mii::$app->emailqueue->push(new EmailJob([ 'to' => 'mail@yiiframework.com', 'body' => 'Hi guys! Thank you for your framework!', ]));
To execute task you need to start console command:
# This command executes tasks in a loop until the queue is empty: mii queue run --queue=emailqueue # This command launches a daemon which infinitely queries the queue: mii queue listen --queue=emailqueue