PHPackages                             yiisoft/yii-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. [Framework](/categories/framework)
4. /
5. yiisoft/yii-queue

Abandoned → [yiisoft/queue](/?search=yiisoft%2Fqueue)Library[Framework](/categories/framework)

yiisoft/yii-queue
=================

Queue Extension which supported DB, Redis, RabbitMQ, Beanstalk, SQS and Gearman

5438.0k↓42.9%30[5 issues](https://github.com/yiisoft/yii-queue/issues)[4 PRs](https://github.com/yiisoft/yii-queue/pulls)PHPCI passing

Since Dec 17Pushed 1w ago16 watchersCompare

[ Source](https://github.com/yiisoft/yii-queue)[ Packagist](https://packagist.org/packages/yiisoft/yii-queue)[ RSS](/packages/yiisoft-yii-queue/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependenciesVersions (10)Used By (0)

 [ ![Yii](https://camo.githubusercontent.com/8317c17418b39410a660f5149071d26c5023c0d5fb2b7ebb771324812f666d73/68747470733a2f2f796969736f66742e6769746875622e696f2f646f63732f696d616765732f7969695f6c6f676f2e737667) ](https://github.com/yiisoft)

Yii Queue
=========

[](#yii-queue)

[![Latest Stable Version](https://camo.githubusercontent.com/3efb52e78b8fd13f07c5e20acca66aca72a4006cbe5bf70706a17c02464e6e94/68747470733a2f2f706f7365722e707567782e6f72672f796969736f66742f71756575652f762f737461626c652e737667)](https://packagist.org/packages/yiisoft/queue)[![Total Downloads](https://camo.githubusercontent.com/49ec584aaa146f60e43ca87f6b6c2fbe74042ecb5091e06ca540134c61af190f/68747470733a2f2f706f7365722e707567782e6f72672f796969736f66742f71756575652f646f776e6c6f6164732e737667)](https://packagist.org/packages/yiisoft/queue)[![Build status](https://github.com/yiisoft/queue/actions/workflows/build.yml/badge.svg?branch=master)](https://github.com/yiisoft/queue/actions/workflows/build.yml?query=branch%3Amaster)[![Code coverage](https://camo.githubusercontent.com/6bca82a7adb649ebe0cc9cca8143df54f8847ce5fabd8aae27d5d2e8cf71340f/68747470733a2f2f636f6465636f762e696f2f67682f796969736f66742f71756575652f67726170682f62616467652e7376673f746f6b656e3d4e553253543031423155)](https://codecov.io/gh/yiisoft/queue)[![Mutation testing badge](https://camo.githubusercontent.com/cbf3c887f24e6fda2d2b158e68ff8e458f15f572d08f511463e47c62a339b634/68747470733a2f2f696d672e736869656c64732e696f2f656e64706f696e743f7374796c653d666c61742675726c3d687474707325334125324625324662616467652d6170692e737472796b65722d6d757461746f722e696f2532466769746875622e636f6d253246796969736f667425324671756575652532466d6173746572)](https://dashboard.stryker-mutator.io/reports/github.com/yiisoft/queue/master)[![Static analysis](https://github.com/yiisoft/queue/actions/workflows/static.yml/badge.svg?branch=master)](https://github.com/yiisoft/queue/actions/workflows/static.yml?query=branch%3Amaster)[![type-coverage](https://camo.githubusercontent.com/0a3bb447cb4abc8e66580a4407589dac0594dca4f6ea641450a45d0a2ff07fca/68747470733a2f2f73686570686572642e6465762f6769746875622f796969736f66742f71756575652f636f7665726167652e737667)](https://shepherd.dev/github/yiisoft/queue)

A framework-agnostic PHP queue library for running tasks asynchronously, best used with Yii3 applications.

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

[](#requirements)

- PHP 8.1 - 8.5.
- PCNTL extension for signal handling *(optional, recommended for production use)*.

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

[](#installation)

The package could be installed with [Composer](https://getcomposer.org):

```
composer require yiisoft/queue
```

Quick Start
-----------

[](#quick-start)

### 1. Install an adapter

[](#1-install-an-adapter)

For production use, you should install an adapter package that matches your message broker ([AMQP](https://github.com/yiisoft/queue-amqp), [Kafka](https://github.com/g41797/queue-kafka), [NATS](https://github.com/g41797/queue-nats), and [others](docs/guide/en/adapter-list.md)). See the [adapter list](docs/guide/en/adapter-list.md) and follow the adapter-specific documentation for installation and configuration details.

> If you don't have an external broker — whether for development, testing, or because you want to design around `QueueInterface` from day one and add a real broker later — you can run the queue in [synchronous mode](docs/guide/en/synchronous-mode.md) (the adapter argument is optional). In this mode messages are processed immediately in the same process, so it won't provide true async execution, but the code stays the same when you switch to a real adapter.

### 2. Prepare a message and handler

[](#2-prepare-a-message-and-handler)

Define a message class for the work to be done — a simple value object with typed properties:

```
use Yiisoft\Queue\Message\Message;

final class DownloadFileMessage extends Message
{
    public const TYPE = 'download-file';

    public function __construct(
        public readonly string $url,
        public readonly string $destinationPath,
    ) {}

    public static function fromPayload(string $type, bool|int|float|string|array|null $payload): static
    {
        if ($type !== self::TYPE) {
            throw new \InvalidArgumentException("Expected type \"" . self::TYPE . "\", got \"$type\".");
        }
        if (!is_array($payload)
            || !is_string($payload['url'] ?? null)
            || !is_string($payload['destinationPath'] ?? null)
        ) {
            throw new \InvalidArgumentException('Invalid data for ' . self::class . '.');
        }
        return new self($payload['url'], $payload['destinationPath']);
    }

    public function getType(): string
    {
        return self::TYPE;
    }

    public function getPayload(): array
    {
        return ['url' => $this->url, 'destinationPath' => $this->destinationPath];
    }
}
```

Then create a handler that processes it:

```
use Yiisoft\Queue\Message\MessageInterface;
use Yiisoft\Queue\Message\MessageHandlerInterface;

final readonly class RemoteFileHandler implements MessageHandlerInterface
{
    public function __construct(
        private FileDownloader $downloader,
        private FileProcessor $processor,
    ) {}

    public function handle(MessageInterface $message): void
    {
        assert($message instanceof DownloadFileMessage);
        $localPath = $this->downloader->download($message->url, $message->destinationPath);
        $this->processor->process($localPath);
    }
}
```

### 3. Configure the queue

[](#3-configure-the-queue)

#### Configuration with [yiisoft/config](https://github.com/yiisoft/config)

[](#configuration-with-yiisoftconfig)

**If you use [yiisoft/app](https://github.com/yiisoft/app) or [yiisoft/app-api](https://github.com/yiisoft/app-api)**

Add queue configuration to your application `$params` config. In [yiisoft/app](https://github.com/yiisoft/app)/[yiisoft/app-api](https://github.com/yiisoft/app-api) templates it's typically the `config/params.php` file. *If your project structure differs, put it into any params config file that is loaded by [yiisoft/config](https://github.com/yiisoft/config).*

Minimal configuration example:

```
return [
    'yiisoft/queue' => [
        'handlers' => [
            DownloadFileMessage::TYPE => RemoteFileHandler::class,
        ],
    ],
];
```

[Advanced configuration with `yiisoft/config`](docs/guide/en/configuration-with-config.md)

#### Manual configuration

[](#manual-configuration)

For setting up all classes manually, see the [Manual configuration](docs/guide/en/configuration-manual.md) guide.

### 4. Send (produce/push) a message to a queue

[](#4-send-producepush-a-message-to-a-queue)

To send a message to the queue, get the queue instance and call `push()`. Typically the queue is injected as a dependency:

```
final readonly class Foo
{
    public function __construct(private QueueInterface $queue) {}

    public function bar(): void
    {
        $this->queue->push(new DownloadFileMessage(
            url: 'https://example.com/file-path.csv',
            destinationPath: '/tmp/file-path.csv',
        ));
    }
}
```

### 5. Handle queued messages

[](#5-handle-queued-messages)

By default, Yii Framework uses [yiisoft/yii-console](https://github.com/yiisoft/yii-console) to run CLI commands. If you installed [yiisoft/app](https://github.com/yiisoft/app) or [yiisoft/app-api](https://github.com/yiisoft/app-api), you can run the queue worker with one of these two commands:

```
./yii queue:run # Handle all existing messages in the queue
./yii queue:listen [queueName] # Start a daemon listening for new messages permanently from the specified queue
./yii queue:listen-all [queueName [queueName2 [...]]] # Start a daemon listening for new messages permanently from all queues or specified list of queues (use with caution in production, recommended for dev only)
```

See [Console commands](docs/guide/en/console-commands.md) for more details.

> In case you're running the queue in synchronous mode (no adapter), `queue:listen` logs an info message and exits. The messages are processed immediately when pushed.

Documentation
-------------

[](#documentation)

- [Guide](docs/guide/en/README.md)
- [Internals](docs/internals.md)

If you need help or have a question, the [Yii Forum](https://forum.yiiframework.com/c/yii-3-0/63) is a good place for that. You may also check out other [Yii Community Resources](https://www.yiiframework.com/community).

Versioning
----------

[](#versioning)

This package follows [semantic versioning](https://semver.org/).

The `/stubs` directory is intended for testing purposes only and must not be used in production code. Any changes there, including breaking ones, are always released as a patch version.

License
-------

[](#license)

The Yii Queue is free software. It is released under the terms of the BSD License. Please see [`LICENSE`](./LICENSE.md) for more information.

Maintained by [Yii Software](https://www.yiiframework.com/).

### Support the project

[](#support-the-project)

[![Open Collective](https://camo.githubusercontent.com/a2b15f8e2268d4e3842e00d41ff7a57cce2ad8bd8d8769c5dc4fa05a546a4f62/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4f70656e253230436f6c6c6563746976652d73706f6e736f722d3765616466313f6c6f676f3d6f70656e253230636f6c6c656374697665266c6f676f436f6c6f723d376561646631266c6162656c436f6c6f723d353535353535)](https://opencollective.com/yiisoft)

### Follow updates

[](#follow-updates)

[![Official website](https://camo.githubusercontent.com/d6b0929173e28cc627430d2519ca1853466a70f37395877eaf4820cb3e1e1909/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f506f77657265645f62792d5969695f4672616d65776f726b2d677265656e2e7376673f7374796c653d666c6174)](https://www.yiiframework.com/)[![Twitter](https://camo.githubusercontent.com/d077c362ac639792171af8bc002ee827816733dfc0925f70b557e6d151022226/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f747769747465722d666f6c6c6f772d3144413146323f6c6f676f3d74776974746572266c6f676f436f6c6f723d314441314632266c6162656c436f6c6f723d3535353535353f7374796c653d666c6174)](https://twitter.com/yiiframework)[![Telegram](https://camo.githubusercontent.com/4e38dd12535575c39c65bea7119b95e663abb2d1f4e3d669a27bbda07ef603f0/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f74656c656772616d2d6a6f696e2d3144413146323f7374796c653d666c6174266c6f676f3d74656c656772616d)](https://t.me/yii3en)[![Facebook](https://camo.githubusercontent.com/48204e301b34b29b0815854544f04c337fc0692096cab35e9a1f8c53a42c2307/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f66616365626f6f6b2d6a6f696e2d3144413146323f7374796c653d666c6174266c6f676f3d66616365626f6f6b266c6f676f436f6c6f723d666666666666)](https://www.facebook.com/groups/yiitalk)[![Slack](https://camo.githubusercontent.com/1a3645ba1c97e6684d0349bc478201e1621ba0d3efad516d81035364d442bad7/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f736c61636b2d6a6f696e2d3144413146323f7374796c653d666c6174266c6f676f3d736c61636b)](https://yiiframework.com/go/slack)

###  Health Score

42

—

FairBetter than 88% of packages

Maintenance62

Regular maintenance activity

Popularity41

Moderate usage in the ecosystem

Community32

Small or concentrated contributor base

Maturity32

Early-stage or recently created project

 Bus Factor2

2 contributors hold 50%+ of commits

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/261a6249c6f605f3956a2fae40fbb813f6b2e1e6f2bf806180c851a965426e54?d=identicon)[cebe](/maintainers/cebe)

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

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

![](https://www.gravatar.com/avatar/99106256c24a8cb23871b99fa90e48f37f1aa71608c185759b7d2a88683a5918?d=identicon)[hiqsol](/maintainers/hiqsol)

---

Top Contributors

[![zhuravljov](https://avatars.githubusercontent.com/u/1656851?v=4)](https://github.com/zhuravljov "zhuravljov (321 commits)")[![viktorprogger](https://avatars.githubusercontent.com/u/7670669?v=4)](https://github.com/viktorprogger "viktorprogger (106 commits)")[![samdark](https://avatars.githubusercontent.com/u/47294?v=4)](https://github.com/samdark "samdark (65 commits)")[![vjik](https://avatars.githubusercontent.com/u/525501?v=4)](https://github.com/vjik "vjik (59 commits)")[![xepozz](https://avatars.githubusercontent.com/u/6815714?v=4)](https://github.com/xepozz "xepozz (30 commits)")[![kids-return](https://avatars.githubusercontent.com/u/4520936?v=4)](https://github.com/kids-return "kids-return (12 commits)")[![machour](https://avatars.githubusercontent.com/u/304450?v=4)](https://github.com/machour "machour (11 commits)")[![s1lver](https://avatars.githubusercontent.com/u/4567634?v=4)](https://github.com/s1lver "s1lver (10 commits)")[![romkatsu](https://avatars.githubusercontent.com/u/1677515?v=4)](https://github.com/romkatsu "romkatsu (8 commits)")[![devanych](https://avatars.githubusercontent.com/u/20116244?v=4)](https://github.com/devanych "devanych (8 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (6 commits)")[![Lesha701](https://avatars.githubusercontent.com/u/22198779?v=4)](https://github.com/Lesha701 "Lesha701 (6 commits)")[![softark](https://avatars.githubusercontent.com/u/342857?v=4)](https://github.com/softark "softark (5 commits)")[![terabytesoftw](https://avatars.githubusercontent.com/u/42547589?v=4)](https://github.com/terabytesoftw "terabytesoftw (5 commits)")[![SilverFire](https://avatars.githubusercontent.com/u/4499203?v=4)](https://github.com/SilverFire "SilverFire (5 commits)")[![Fantom409](https://avatars.githubusercontent.com/u/14968877?v=4)](https://github.com/Fantom409 "Fantom409 (4 commits)")[![g41797](https://avatars.githubusercontent.com/u/9116281?v=4)](https://github.com/g41797 "g41797 (4 commits)")[![StyleCIBot](https://avatars.githubusercontent.com/u/11048387?v=4)](https://github.com/StyleCIBot "StyleCIBot (4 commits)")[![dependabot-preview[bot]](https://avatars.githubusercontent.com/in/2141?v=4)](https://github.com/dependabot-preview[bot] "dependabot-preview[bot] (3 commits)")[![rustamwin](https://avatars.githubusercontent.com/u/16498265?v=4)](https://github.com/rustamwin "rustamwin (3 commits)")

---

Tags

amqpbeanstalkhacktoberfestkafkanatsoptionalforframeworkannouncepulsarqueuerabbitmqredissqsvalkeyyii3

### Embed Badge

![Health badge](/badges/yiisoft-yii-queue/health.svg)

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

###  Alternatives

[laravel/dusk

Laravel Dusk provides simple end-to-end testing and browser automation.

1.9k39.6M299](/packages/laravel-dusk)[nineinchnick/edatatables

Grid widget for the Yii Framework, wrapper for the DataTables jQuery plugin

173.2k](/packages/nineinchnick-edatatables)[link-cloud/fast-hyperf

LinkCloud Fast Hyperf

241.2k1](/packages/link-cloud-fast-hyperf)

PHPackages © 2026

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