PHPackages                             balpom/symfony-messenger-and-workerman - 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. [Database &amp; ORM](/categories/database)
4. /
5. balpom/symfony-messenger-and-workerman

ActiveLibrary[Database &amp; ORM](/categories/database)

balpom/symfony-messenger-and-workerman
======================================

A simple example of using a Workerman with Symfony Messenger.

v2.0.2(1y ago)011MITPHPPHP &gt;=8.1

Since Jun 3Pushed 1y ago1 watchersCompare

[ Source](https://github.com/balpom/symfony-messenger-and-workerman)[ Packagist](https://packagist.org/packages/balpom/symfony-messenger-and-workerman)[ Docs](https://www.balpom.ru)[ RSS](/packages/balpom-symfony-messenger-and-workerman/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (5)Dependencies (8)Versions (6)Used By (0)

symfony-messenger-and-workerman
===============================

[](#symfony-messenger-and-workerman)

A simple example showing how to use Workerman and a Symfony Messenger with queues.
----------------------------------------------------------------------------------

[](#a-simple-example-showing-how-to-use-workerman-and-a-symfony-messenger-with-queues)

Not finding a simple and complete example of using the [Symfony Messenger](https://github.com/symfony/messenger/), I create it myself: . It use Doctrine with sqlite database as Message Bus transport and for Workers running it use [Symfony Console](https://github.com/symfony/console/).

However, my inner perfectionist :-) does not like the idea, when manually open the console, run a script in it, etc. I wanted to use a single command to open several consoles at once in the right amount, in which the worker's would already be working, and if one of the workers fell, the console was restarting itself (a set number of running consoles (scripts) was supported).

As a result, I created a new example, in which I completely abandoned the symfony/console component, and for Workers starting and for maintaining a set number of them, I use [Workerman](https://github.com/walkor/workerman) framework ().

Everything was tested in Linux.

### Requirements

[](#requirements)

- **PHP &gt;= 8.1**

### Installation

[](#installation)

#### Using composer (recommended)

[](#using-composer-recommended)

```
composer create balpom/symfony-messenger-and-workerman
```

How to use
----------

[](#how-to-use)

Open console window. Run the command:

```
php bin/start
```

It starts three simple Worker, which imitate SMS sending. Now it is waiting for messages to be sent from the queue, which is still empty.

Run the command:

```
php tests/send.php
```

It runs a simple script that adds some several messages to the queue. After this, in previously automatically opened consoles you may see, how several Workers "sending" SMS.

Run the command:

```
php tests/sendmany.php
```

It runs a simple script that adds many several messages to the queue.

Run the command:

```
php bin/reload
```

It reloads all Workers. After reloading all Workers continue execution.

Run the command:

```
php bin/stop
```

It stop all Workers executions.

Specificity
-----------

[](#specificity)

Created by me SymfonyWorker class is a wrapper for Symfony\\Component\\Messenger\\Worker and built on the base of the ConsumeMessagesCommand class (Symfony\\Component\\Messenger\\Command\\ConsumeMessagesCommand).

For Workerman\\Worker running I created very simple script bin/runner:

```
namespace Balpom\SymfonyMessengerWorkerman;
use Workerman\Worker;
use Symfony\Component\Process\Process;

Worker::$daemonize = true; // Always run as daemon.
$worker = new Worker();
$worker->count = 3;        // Numbef of Workers.

$worker->onWorkerStart = function (Worker $worker) {
    //$process = new Process(['php', 'bin/start_worker']);
    //SymfonyWorkerFactory::getWorker(__DIR__ . '/../config/dependencies.php')->run();

    $pid = \posix_getpid(); // Current Workerman's Worker PID.
    $line = 'bash -c "gnome-terminal --wait -- php bin/start_worker; kill -SIGQUIT ' . $pid . '"';
    $process = Process::fromShellCommandline($line);
    $process->run();
};

Worker::runAll();
```

It has line `$line = 'bash -c "gnome-terminal --wait -- php bin/start_worker; kill -SIGQUIT ' . $pid . '"';`If you don't have *gnome-terminal* in your system, you must replace this line to the line, that runs the command "php bin/start\_worker" for your terminal.

Also you may run, stop and reload workers directly from "bin/runner" script by this commands:

```
php bin/runner start
php bin/runner reload
php bin/runner stop
```

For current status checking try this command:

```
php bin/runner status
```

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance31

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 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 ~1 days

Total

5

Last Release

707d ago

Major Versions

v1.0.1 → v2.0.02024-06-05

### Community

Maintainers

![](https://www.gravatar.com/avatar/5604ae7cc0bdc12fd8cf8867f3518ec3c9628f13707f127e700cdac1aec70b56?d=identicon)[balpom](/maintainers/balpom)

---

Top Contributors

[![balpom](https://avatars.githubusercontent.com/u/141855513?v=4)](https://github.com/balpom "balpom (15 commits)")

---

Tags

symfonysqlitedoctrinequeuetransportexampleworkerusageMessengerworkermanusesample

### Embed Badge

![Health badge](/badges/balpom-symfony-messenger-and-workerman/health.svg)

```
[![Health](https://phpackages.com/badges/balpom-symfony-messenger-and-workerman/health.svg)](https://phpackages.com/packages/balpom-symfony-messenger-and-workerman)
```

###  Alternatives

[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M152](/packages/sulu-sulu)[prestashop/prestashop

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.0k15.4k](/packages/prestashop-prestashop)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

595.2M386](/packages/shopware-core)[open-dxp/opendxp

Content &amp; Product Management Framework (CMS/PIM)

7310.3k29](/packages/open-dxp-opendxp)[bartlett/php-compatinfo-db

Reference Database of all functions, constants, classes, interfaces on PHP standard distribution and about 110 extensions

1183.0k1](/packages/bartlett-php-compatinfo-db)

PHPackages © 2026

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