PHPackages                             atlasmobile/yii2-queue - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Queues &amp; Workers](/categories/queues)
4. /
5. atlasmobile/yii2-queue

ActiveYii2-extension[Queues &amp; Workers](/categories/queues)

atlasmobile/yii2-queue
======================

yii2 queue component

1.1.5(10y ago)25.2kBSD-4-ClausePHP

Since Dec 21Pushed 10y ago4 watchersCompare

[ Source](https://github.com/AtlasGit/yii2-queue)[ Packagist](https://packagist.org/packages/atlasmobile/yii2-queue)[ RSS](/packages/atlasmobile-yii2-queue/feed)WikiDiscussions master Synced 4w ago

READMEChangelog (1)Dependencies (2)Versions (15)Used By (0)

Queue component for Yii2
========================

[](#queue-component-for-yii2)

This component provides simple queue wrapper

Requirements
------------

[](#requirements)

[Redis](http://redis.io)

[yii2-redis](https://github.com/yiisoft/yii2-redis)

Installation
------------

[](#installation)

The preferred way to install this extension is through [composer](http://getcomposer.org/download/).

Either run

```
composer require --prefer-dist "atlasmobile/yii2-queue=*"

```

or add

```
"atlas/yii2-queue": "*"

```

to the require section of your `composer.json` file.

Application configuration
-------------------------

[](#application-configuration)

To use this extension, simply add the following code in your application configuration:

```
return [
    //....
    'components' => [
        'queue' => [
            'class' => \atlasmobile\queue\RedisQueue::class,
        ],
        'redis' => [
            'class' => \yii\redis\Connection::class,
            'hostname' => 'localhost',
            'port' => 6379,
            'database' => 0
        ],

        'controllerMap' => [
            'queue' => \atlasmobile\queue\console\controllers\QueueController::class,
        ],
    ],
];
```

First Job
---------

[](#first-job)

First create a Job process class

```
namespace console\jobs;

class MyJob implements \atlasmobile\queue\QueueHandler
{
    public function run(\atlasmobile\queue\Job $job, $data)
    {
        //process $data;
        var_dump($data);
    }
}
```

OR

```
namespace console\jobs;

class MyJob extends \atlasmobile\queue\BaseTask
{
	public function beforeRun(Job $job, QueuePayload $payload) {
		//todo before running task
	}

    public function run(\atlasmobile\queue\Job $job, $data)
    {
        //process $data;
        var_dump($data);
    }

    public function afterRun(Job $job, QueuePayload $payload) {
    	//todo after running task
    }

    public function onFail(Job $job, QueuePayload $payload, \Exception $exception) {
    	//todo what to do on fail running task
    }
}
```

and than just push job to queue

```
// You can use component directly or static method to push job to queue:
\atlasmobile\queue\helpers\Queue::push($job, $data = null, $queue = 'default', $options = [])

// Push job to the default queue and execute "run" method
Yii::$app->queue->push(\console\jobs\MyJob::class, ['a', 'b', 'c']);

// or push it and execute any other method
Yii::$app->queue->push('\console\jobs\MyJob@myMethod', ['a', 'b', 'c']);

// or push it to some specific queue
Yii::$app->queue->push(\console\jobs\MyJob::class, ['a', 'b', 'c'], 'myQueue');

// or both
Yii::$app->queue->push('\console\jobs\MyJob@myMethod', ['a', 'b', 'c'], 'myQueue');
```

#### Since 1.0.5 available delayed tasks

[](#since-105-available-delayed-tasks)

```
// Just a string
Yii::$app->queue->pushDelayed(\console\jobs\MyJob::class, '+3 hours', ['a', 'b', 'c']);

// Or \DateTime
$dt = new \DateTime('now');
$dt->modify('+1 week')->modify('+3 days');
Yii::$app->queue->pushDelayed(\console\jobs\MyJob::class, $dt, ['a', 'b', 'c']);

// Or oldschool
Yii::$app->queue->pushDelayed(\console\jobs\MyJob::class, time() + 86400, ['a', 'b', 'c']);
```

Listener
--------

[](#listener)

### If you wanna use supervisor, put this config:

[](#if-you-wanna-use-supervisor-put-this-config)

```
[program:yiiqueue]
command=php /path/to/project/yii queue/listen
process_name=%(program_name)s_%(process_num)02d
numprocs=4  ; customize workers
directory=/path/to/project
autostart=true
autorestart=true
user=nginx ; executor user
stdout_logfile=/path/to/project/runtime/logs/queue.out.log
stdout_logfile_maxbytes=10MB
stderr_logfile=/path/to/project/runtime/logs/queue.err.log
stderr_logfile_maxbytes=10MB
```

### Queue listener examples:

[](#queue-listener-examples)

```
# Process a first job from default queue and than exit the process
./yii queue/work

# continuously process jobs from default queue
./yii queue/listen

# process a job from specific queue and than exit the process
./yii queue/work --queue=queueName

# continuously process jobs from specific queue
./yii queue/listen --queue=myQueue

```

### Delayed listener examples (since 1.0.5):

[](#delayed-listener-examples-since-105)

```
# Pop list of delayed jobs and if "time to work", puts them to queue
./yii queue/delayed

# Or for supervisor or just for "&"
./yii queue/listen-delayed
```

Method listen-delayed by defaults check new delayed jobs every 30 seconds, but u can set --pollFreqSecs=MY\_SECONDS

### Also you can store failed jobs into db

[](#also-you-can-store-failed-jobs-into-db)

First, run migration to create table with failed jobs

```
 ./yii queue/failed-table

```

and run

```
./yii queue/listen --storeFailedJobs=true

```

Then after some time when table will filled with failed jobs, do next:

```
./yii queue/failed
```

This command will add to queue all failed jobs in [FIFO](https://en.wikipedia.org/wiki/FIFO_and_LIFO_accounting) (first-in-first-out) order

To flush table with failed jobs:

```
./yii queue/failed-flush
```

### Monitor

[](#monitor)

In some cases you may want to see how much and/or what jobs are queued now. To see basic information, use:

```
./yii queue/monitor
```

###  Health Score

35

—

LowBetter than 77% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity20

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity71

Established project with proven stability

 Bus Factor1

Top contributor holds 83.1% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~13 days

Recently: every ~2 days

Total

13

Last Release

3681d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/e642922ac3d57570cf8d42007199107da7491d34a573ddd90892e824f18e6a1c?d=identicon)[edwardstock](/maintainers/edwardstock)

---

Top Contributors

[![edwardstock](https://avatars.githubusercontent.com/u/1484961?v=4)](https://github.com/edwardstock "edwardstock (49 commits)")[![mikk150](https://avatars.githubusercontent.com/u/4953629?v=4)](https://github.com/mikk150 "mikk150 (4 commits)")[![bryglen](https://avatars.githubusercontent.com/u/875604?v=4)](https://github.com/bryglen "bryglen (2 commits)")[![tsacks](https://avatars.githubusercontent.com/u/2553898?v=4)](https://github.com/tsacks "tsacks (1 commits)")[![lichunqiang](https://avatars.githubusercontent.com/u/2433916?v=4)](https://github.com/lichunqiang "lichunqiang (1 commits)")[![chebureque](https://avatars.githubusercontent.com/u/1630226?v=4)](https://github.com/chebureque "chebureque (1 commits)")[![lynicidn](https://avatars.githubusercontent.com/u/7407411?v=4)](https://github.com/lynicidn "lynicidn (1 commits)")

---

Tags

queueyii2extension

### Embed Badge

![Health badge](/badges/atlasmobile-yii2-queue/health.svg)

```
[![Health](https://phpackages.com/badges/atlasmobile-yii2-queue/health.svg)](https://phpackages.com/packages/atlasmobile-yii2-queue)
```

###  Alternatives

[trntv/yii2-command-bus

Yii2 Command Bus extension

57647.2k8](/packages/trntv-yii2-command-bus)[ignatenkovnikita/yii2-queuemanager

Yii2 Queue Manager

2062.9k2](/packages/ignatenkovnikita-yii2-queuemanager)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
