PHPackages                             kozhemin/yii2-background-task-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. kozhemin/yii2-background-task-queue

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

kozhemin/yii2-background-task-queue
===================================

Yii2 background task queue Extension is a simple and easy-to-use extension for running background tasks in Yii2 applications

1.0.0(1y ago)01MITPHP

Since Jan 16Pushed 1y ago1 watchersCompare

[ Source](https://github.com/kozhemin/yii2-background-task-queue)[ Packagist](https://packagist.org/packages/kozhemin/yii2-background-task-queue)[ RSS](/packages/kozhemin-yii2-background-task-queue/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (1)Versions (2)Used By (0)

Yii2 background task queue Extension
====================================

[](#yii2-background-task-queue-extension)

Yii2 background task queue Extension is a simple and easy-to-use extension for running background tasks in Yii2 applications.

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

[](#installation)

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

```
composer require kozhemin/yii2-background-task-queue
```

### migration

[](#migration)

```
php yii migrate --migrationPath=@vendor/kozhemin/yii2-background-task-queue/migrations
```

Basic Usage
-----------

[](#basic-usage)

```
use kozhemin\backgroundTaskQueue\TaskPublisher;

$task = new MySimpleTask();
$taskPublisher = new TaskPublisher($task);
$queue = $taskPublisher
    ->setDescription('My simple task')
    ->setDelay(60)
    ->publish();

    if ($queue->hasErrors()) {
        echo "\nTask not created. Errors: " . implode(', ', $queue->getFirstErrors()) . "\n";
        return ExitCode::UNSPECIFIED_ERROR;
    }

    echo "\nTask created with id: " . $queue->uuid . "\n";
```

### Task class example

[](#task-class-example)

```
use kozhemin\backgroundTaskQueue\contracts\HandlerInterface;
use kozhemin\backgroundTaskQueue\contracts\TaskResponseInterface;
use kozhemin\backgroundTaskQueue\TaskResponse;

class MySimpleTask implements HandlerInterface
{
    public function run(): TaskResponseInterface
    {
        // some code here
        echo "Start task\n";
        sleep(3);
        echo "End task\n";

        $response = new TaskResponse();
        $response->setMessage(['firstResponseMsg' => 'Hello from task1!']);
        $response->appendMessage(['secondResponseMsg' => 'Hello from task2!']);

        return $response;
    }
}
```

### all commands

[](#all-commands)

```
- task-queue                   Controller for managing background tasks.
    task-queue/run             Runs the task.
    task-queue/ls              Displays a list of tasks.
    task-queue/info            Displays information about the task.
    task-queue/cancel          Cancels the task.
    task-queue/retry           Retries the task.

```

### run task

[](#run-task)

```
# run task
php yii task-queue/run

# or with uuid
php yii task-queue/run
```

### example crontab

[](#example-crontab)

```
# run task every minute
* * * * * php yii task-queue/run

# run task every 30 seconds
* * * * * php yii task-queue/run
* * * * * sleep 30 && php yii task-queue/run

# run every 10 seconds
* * * * * php yii task-queue/run
* * * * * sleep 10 && php yii task-queue/run
* * * * * sleep 20 && php yii task-queue/run
* * * * * sleep 30 && php yii task-queue/run
* * * * * sleep 40 && php yii task-queue/run
* * * * * sleep 50 && php yii task-queue/run
```

### listen task

[](#listen-task)

```
php yii task-queue/ls

# or with status filter
php yii task-queue/ls --limit=10 --status=0,1,2,3

# run help command for more options
php yii help task-queue/ls
```

### example listen task real time

[](#example-listen-task-real-time)

```
# run listen task real time
watch -n 1 php yii task-queue/ls
```

### Screenshots

[](#screenshots)

```
# task list
php yii task-queue/ls --status=0,1,2,3
```

[![Screenshot](img/task_list.png)](img/task_list.png)

```
# task info
php yii task-queue/info 67895e8b58fbb
```

[![Screenshot](img/task_info.png)](img/task_info.png)

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance43

Moderate activity, may be stable

Popularity1

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity37

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% 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

Unknown

Total

1

Last Release

477d ago

### Community

Maintainers

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

---

Top Contributors

[![kozhemin](https://avatars.githubusercontent.com/u/7480673?v=4)](https://github.com/kozhemin "kozhemin (1 commits)")

---

Tags

yii2background task queue

### Embed Badge

![Health badge](/badges/kozhemin-yii2-background-task-queue/health.svg)

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

###  Alternatives

[trntv/yii2-command-bus

Yii2 Command Bus extension

57625.1k8](/packages/trntv-yii2-command-bus)[mikemadisonweb/yii2-rabbitmq

Wrapper based on php-amqplib to incorporate messaging in your Yii2 application via RabbitMQ. Inspired by RabbitMqBundle for Symfony 2, really awesome package.

74262.1k1](/packages/mikemadisonweb-yii2-rabbitmq)[udokmeci/yii2-beanstalk

Yii2 Beanstalk Client at the top of Paul Annesley's pheanstalk

69125.3k3](/packages/udokmeci-yii2-beanstalk)[bubasuma/yii2-simplechat

A simple chat for your yii2 application

889.5k](/packages/bubasuma-yii2-simplechat)[ignatenkovnikita/yii2-queuemanager

Yii2 Queue Manager

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

PHPackages © 2026

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