fk/queue

PHP based queue execution program

v2.0.0 2017-11-30 02:30 UTC

This package is not auto-updated.

Last update: 2024-04-27 17:42:23 UTC


README

Extension can work as yii extension too

  1. register as a component
# main.php
return [
    'components' => [
        'queue' => [
            'class' => 'fk\queue\wrapper\yii2\Connection',
            'logPath' => '@console/runtime/logs/queue.log',
            'engine' => 'fk\queue\engines\Redis',
        ]
    ]
]
  1. queue in
Yii::$app->queue->in('ls -l'); // bash> ls -l
Yii::$app->queue->in(new YiiCommand(['migrate'])); // bash> php yii migrate

You can write your own XXCommand to parse a command, but in the end, a bash command should be returned If the argument for in is empty, then the cmd will be ignored

  1. map of console
# console\config\main.php
return [
    'controllerMap' => [
        'queue' => [
            'class' => 'fk\queue\wrapper\yii2\QueueController'
        ]
    ],
]
  1. queue start
php yii queue/start

Command

Writing your own command by extends \fk\queue\commands\Command and overwrite method CommandInterface::parse

<?php

class MyCommand extends \fk\queue\commands\Command
{

    public $command;

    public function parse() {
        // Parse your command with its property `command`
    }
}