PHPackages                             jc-it/yii2-job-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. jc-it/yii2-job-queue

ActiveLibrary[Queues &amp; Workers](/categories/queues)

jc-it/yii2-job-queue
====================

Job Queue implementation.

v4.0.0(4mo ago)02.6k1[1 PRs](https://github.com/JC-IT/yii2-job-queue/pulls)2MITPHPPHP &gt;=8.3CI failing

Since Dec 7Pushed 4mo ago1 watchersCompare

[ Source](https://github.com/JC-IT/yii2-job-queue)[ Packagist](https://packagist.org/packages/jc-it/yii2-job-queue)[ RSS](/packages/jc-it-yii2-job-queue/feed)WikiDiscussions master Synced today

READMEChangelog (7)Dependencies (9)Versions (8)Used By (2)

Job Queue for Yii2 (based on Beanstalkd)
========================================

[](#job-queue-for-yii2-based-on-beanstalkd)

[![Scrutinizer Code Quality](https://camo.githubusercontent.com/fa2baefc691942290d5903f9bbbdb2880812c3bb8f742030f12c8ca4aeaaad54/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f4a432d49542f796969322d6a6f622d71756575652f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/JC-IT/yii2-job-queue/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/40fea63f0d502525fa0b2e5b707d09893be396460038e4c495ed1d9fc549bfeb/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f4a432d49542f796969322d6a6f622d71756575652f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/JC-IT/yii2-job-queue/?branch=master)[![Build Status](https://camo.githubusercontent.com/971669037818697c538c3efbdbe301d8de0ecb54e799262d6f02499664205501/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f4a432d49542f796969322d6a6f622d71756575652f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/JC-IT/yii2-job-queue/build-status/master)

This extension provides a package that implements a queue, workers and jobs.

```
$ composer require jc-it/yii2-job-queue
```

or add

```
"jc-it/yii2-job-queue": ""

```

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

Configuration
-------------

[](#configuration)

- You need to have Beanstalk installed (`sudo apt install beanstalkd`)
- Apply configuration:

```
'container' => [
    'definitions' => [
        \League\Tactician\CommandBus::class => function(\yii\di\Container $container) {
            return new \League\Tactician\CommandBus([
                new \League\Tactician\Handler\CommandHandlerMiddleware (
                    $container->get(\League\Tactician\Handler\CommandNameExtractor\CommandNameExtractor::class),
                    $container->get(\League\Tactician\Handler\Locator\HandlerLocator::class),
                    $container->get(\League\Tactician\Handler\MethodNameInflector\MethodNameInflector::class)
                )
            ]);
        },
        \JCIT\jobqueue\components\ContainerMapLocator::class => function(\yii\di\Container $container) {
            $result = new \JCIT\jobqueue\components\ContainerMapLocator($container);
            // Register handlers here
            // i.e. $result->setHandlerForCommand(\JCIT\jobqueue\jobs\HelloJob::class, \JCIT\jobqueue\jobHandlers\HelloHandler::class);
            return $result;
        },
        \League\Tactician\Handler\CommandNameExtractor\CommandNameExtractor::class => \League\Tactician\Handler\CommandNameExtractor\ClassNameExtractor::class,
        \League\Tactician\Handler\Locator\HandlerLocator::class => \JCIT\jobqueue\components\ContainerMapLocator::class,
        \JCIT\jobqueue\interfaces\JobFactoryInterface::class => \JCIT\jobqueue\factories\JobFactory::class,
        \JCIT\jobqueue\interfaces\JobQueueInterface::class => \JCIT\jobqueue\components\Beanstalk::class,
        \League\Tactician\Handler\MethodNameInflector\MethodNameInflector::class => \League\Tactician\Handler\MethodNameInflector\HandleInflector::class,
        \Pheanstalk\Contract\PheanstalkInterface::class => \JCIT\jobqueue\components\Beanstalk::class,
        \Pheanstalk\Contract\SocketFactoryInterface::class => function() {
            return new \Pheanstalk\SocketFactory('localhost', 11300, 10);
        },
    ]
],
```

- Register Daemon action in controller:

```
public function actions(): array
{
    return [
        'daemon' => \JCIT\jobqueue\actions\DaemonAction::class,
    ];
}
```

- Run action, i.e. `./yii job-queue/daemon`

### Optional: install daemon as service

[](#optional-install-daemon-as-service)

Look [here](https://www.yiiframework.com/extension/yiisoft/yii2-queue/doc/guide/2.0/en/worker) to see an example how a console action can be installed as a linux service.

Quick test
----------

[](#quick-test)

- Execute steps in Configuration
- Register `\JCIT\jobqueue\jobs\HelloJob::class` and `\JCIT\jobqueue\jobHandlers\HelloHandler::class` in the `ContainerMapLocator` (as shown in the configuration)
- Create `JobQueueController` console controller

```
class JobQueueController extends \yii\console\Controller
{
    public $defaultAction = 'daemon';

    public function actionTest(
        \JCIT\jobqueue\interfaces\JobQueueInterface $jobQueue
    ) {
        $task = \Yii::createObject(\JCIT\jobqueue\jobs\HelloJob::class, ['world']);
        $jobQueue->putJob($task);
    }

    /**
     * @return array
     */
    public function actions(): array
    {
        return [
            'daemon' => [
                'class' => \JCIT\jobqueue\actions\DaemonAction::class,
            ]
        ];
    }
}
```

- Run in one console `src/yii job-queue`
- Run in a second console `src/yii job-queue/test`
- The console that runs the daemon will show `Hello world`
- **NOTE** the daemon must be restarted when handlers have changed

Own implementations
-------------------

[](#own-implementations)

- Create Job (that implements `\JCIT\jobqueue\interfaces\JobInterface::class`) which should not do more than carry data
- Create JobHandler (that implements `\JCIT\jobqueue\interfaces\JobHandlerInterface::class`) which handles the handling of the job
    - Injection should be done on construction of the handler

Logging
-------

[](#logging)

To extend with an easy ActiveRecord logging of the jobs, look at .

Recurring jobs
--------------

[](#recurring-jobs)

To extend with easy ActiveRecord based recurring jobs, look at .

Credits
-------

[](#credits)

- [Sam Mousa](https://github.com/SamMousa)
- [Joey Claessen](https://github.com/joester89)

###  Health Score

48

—

FairBetter than 94% of packages

Maintenance75

Regular maintenance activity

Popularity20

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity73

Established project with proven stability

 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

Every ~307 days

Recently: every ~370 days

Total

7

Last Release

139d ago

Major Versions

v1.0.0 → v2.0.02021-04-20

v1.0.1 → v2.0.12021-12-03

v2.0.2 → v3.0.02025-04-10

v3.0.0 → v4.0.02025-12-23

PHP version history (3 changes)v1.0.0PHP &gt;=7.1.0

v2.0.0PHP &gt;=8.0

v3.0.0PHP &gt;=8.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/88359ebe0456645a614e563dfbf0dd025b69ef57221050cb9eb31e3eef4dd0f9?d=identicon)[joester89](/maintainers/joester89)

---

Top Contributors

[![joester89](https://avatars.githubusercontent.com/u/9624366?v=4)](https://github.com/joester89 "joester89 (42 commits)")

###  Code Quality

TestsCodeception

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/jc-it-yii2-job-queue/health.svg)

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

###  Alternatives

[udokmeci/yii2-beanstalk

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

69125.3k3](/packages/udokmeci-yii2-beanstalk)[symfony/beanstalkd-messenger

Symfony Beanstalkd Messenger Bridge

19357.4k2](/packages/symfony-beanstalkd-messenger)[bubasuma/yii2-simplechat

A simple chat for your yii2 application

889.5k](/packages/bubasuma-yii2-simplechat)

PHPackages © 2026

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