PHPackages                             thomasvargiu/laminas-messenger - 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. thomasvargiu/laminas-messenger

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

thomasvargiu/laminas-messenger
==============================

Factories to use the Symfony Messenger in Laminas and Mezzio applications

1.0.2(6y ago)438.1k—6.7%2[1 PRs](https://github.com/thomasvargiu/laminas-messenger/pulls)MITPHPPHP ^7.2CI passing

Since Jan 21Pushed 5mo ago1 watchersCompare

[ Source](https://github.com/thomasvargiu/laminas-messenger)[ Packagist](https://packagist.org/packages/thomasvargiu/laminas-messenger)[ RSS](/packages/thomasvargiu-laminas-messenger/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (16)Versions (9)Used By (0)

laminas-messenger
=================

[](#laminas-messenger)

[![Latest Stable Version](https://camo.githubusercontent.com/8cdba536f1cf266b590db4540edafcb630b4441f22c2dc12d4abf3a94afcbb59/68747470733a2f2f706f7365722e707567782e6f72672f74686f6d61737661726769752f6c616d696e61732d6d657373656e6765722f762f737461626c65)](https://packagist.org/packages/thomasvargiu/laminas-messenger)[![Total Downloads](https://camo.githubusercontent.com/a7d96de929a90d38dd38ab033d339eeca314bf8ae02f26fcf643c96d728717db/68747470733a2f2f706f7365722e707567782e6f72672f74686f6d61737661726769752f6c616d696e61732d6d657373656e6765722f646f776e6c6f616473)](https://packagist.org/packages/thomasvargiu/laminas-messenger)[![License](https://camo.githubusercontent.com/3eea7d20f41b780b7142f6d6d6f609567d291467dac3ea83d6eff5a79f6a1fb7/68747470733a2f2f706f7365722e707567782e6f72672f74686f6d61737661726769752f6c616d696e61732d6d657373656e6765722f6c6963656e7365)](https://packagist.org/packages/thomasvargiu/laminas-messenger)[![Code Coverage](https://camo.githubusercontent.com/9f776db7461eeef0f9dacc1a273360b69222db003351decf9d6ccc390dd3d95c/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f74686f6d61737661726769752f6c616d696e61732d6d657373656e6765722f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/thomasvargiu/laminas-messenger/?branch=master)[![Build Status](https://camo.githubusercontent.com/a3a24283e813ce54e75bc74b3259fb6be63f4fa79694865a11a399b773f73303/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f74686f6d61737661726769752f6c616d696e61732d6d657373656e6765722f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/thomasvargiu/laminas-messenger/build-status/master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/75e5aa77cabfa36511927a879c285df12dcbf318dd375f063701d405d9ddc65d/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f74686f6d61737661726769752f6c616d696e61732d6d657373656e6765722f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/thomasvargiu/laminas-messenger/?branch=master)

Factories to use the Symfony Messenger in Laminas and Mezzio applications (ex zend-framework and zend-expressive)

Usage
-----

[](#usage)

You need to add console commands to your application. The following command services are already configured for you:

- `Symfony\Component\Messenger\Command\ConsumeMessagesCommand`
- `Symfony\Component\Messenger\Command\SetupTransportsCommand`
- `Symfony\Component\Messenger\Command\FailedMessagesRemoveCommand`
- `Symfony\Component\Messenger\Command\FailedMessagesRetryCommand`
- `Symfony\Component\Messenger\Command\FailedMessagesShowCommand`
- `Symfony\Component\Messenger\Command\StopWorkersCommand` (see note below)

To use the `Symfony\Component\Messenger\Command\StopWorkersCommand` command you should set a `CacheItemPoolInterface`implementation (see below).

A default message bus is already configured for you with the following service name: `messenger.bus.default`. You can read the [Symfony documentation](https://symfony.com/doc/current/components/messenger.html) to know how to use it.

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

[](#configuration)

This is an example configuration:

```
use TMV\Laminas\Messenger\Factory;
use Symfony\Component\Messenger;

return [
    'dependencies' => [
        'factories' => [
            'messenger.bus.foo' => [Factory\MessageBusFactory::class, 'messenger.bus.foo'], // the name must be the same as the bus configuration key
            'messenger.transport.async' => [Factory\Transport\TransportFactory::class, 'messenger.transport.async'], // the name must be the same as the transport configuration key
        ],
    ],
    'messenger' => [
        'failure_transport' => null, // your failure transport service name (optional)
        'logger' => null, // your custom logger service name (optional)
        'default_serializer' => SFMessenger\Transport\Serialization\PhpSerializer::class, // default messenger serializer, it should be a service name
        'cache_pool_for_restart_signal' => null, // CacheItemPoolInterface service name implementation if you want to use stop workers command
        'transport_factories' => [
            // here you can add your custom transport factories services
        ],
        'subscribers' => [], // Subscribers (service name) to use with the default event dispatcher factory
        'buses' => [
            'messenger.bus.foo' => [ // bus service name, it should be registered as a service with the same name
                'default_middleware' => true, // if you want to include default middleware (default: true)
                'middleware' => [ // your custom middleware service names
                    My\FooMiddleware::class,
                ],
                'allow_no_handler' => false, // allow no handlers (default: false)
                'handlers' => [ // your handlers
                    My\FooMessageType::class => [
                        My\FooMessageHandler::class,
                    ],
                ],
                'routes' => [
                    My\FooMessageType::class => ['messenger.transport.async'], // route message types to this transport
                ],
            ],
        ],
        'transports' => [
            'messenger.transport.async' => [
                'dsn' => 'amqp://guest:guest@rabbitmq:5672',
                'serializer' => Messenger\Transport\Serialization\PhpSerializer::class, // custom serializer service
                'options' => [
                    'exchange' => [
                        'name' => 'messenger_events',
                    ],
                    'queues' => [
                        'messenger_events' => [],
                    ],
                ],
                'retry_strategy' => [
                    'max_retries' => 3,
                    'delay' => 1000,
                    'multiplier' => 2,
                    'max_delay' => 0,
                ],
            ],
        ],
    ],
];
```

Doctrine Helpers
----------------

[](#doctrine-helpers)

### Middlewares

[](#middlewares)

There are some middleware available for Doctrine:

#### `TMV\Laminas\Messenger\Middleware\DoctrineCloseConnectionMiddleware`

[](#tmvlaminasmessengermiddlewaredoctrinecloseconnectionmiddleware)

Close connection on every message consumed by the worker.

#### `TMV\Laminas\Messenger\Middleware\DoctrinePingConnectionMiddleware`

[](#tmvlaminasmessengermiddlewaredoctrinepingconnectionmiddleware)

Before to handle a message on worker, ping to check whether the connection is open or try to reconnect it.

#### `TMV\Laminas\Messenger\Middleware\DoctrineTransactionMiddleware`

[](#tmvlaminasmessengermiddlewaredoctrinetransactionmiddleware)

For every message, wrap the message handler with a transaction.

### Subscribers

[](#subscribers)

#### `TMV\Laminas\Messenger\Subscriber\DoctrineClearEntityManagerWorkerSubscriber`

[](#tmvlaminasmessengersubscriberdoctrineclearentitymanagerworkersubscriber)

This subscriber clear the EntityManager after a message is handled in a worker.

###  Health Score

41

—

FairBetter than 89% of packages

Maintenance48

Moderate activity, may be stable

Popularity35

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity57

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

Recently: every ~435 days

Total

7

Last Release

475d ago

Major Versions

1.0.2 → 2.0.0-beta12025-01-24

PHP version history (3 changes)1.0.0PHP ^7.2

2.0.0-beta1PHP ^8.1

2.0.0-beta2PHP ^8.0

### Community

Maintainers

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

---

Top Contributors

[![thomasvargiu](https://avatars.githubusercontent.com/u/732012?v=4)](https://github.com/thomasvargiu "thomasvargiu (12 commits)")

---

Tags

messagesymfonyfactorylaminaszendmezziomessagingmoduleAMQPbusexpressiveMessengerservice-bussymfony-messenger

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan, Psalm

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/thomasvargiu-laminas-messenger/health.svg)

```
[![Health](https://phpackages.com/badges/thomasvargiu-laminas-messenger/health.svg)](https://phpackages.com/packages/thomasvargiu-laminas-messenger)
```

###  Alternatives

[php-amqplib/rabbitmq-bundle

Integrates php-amqplib with Symfony &amp; RabbitMq. Formerly emag-tech-labs/rabbitmq-bundle, oldsound/rabbitmq-bundle.

1.3k20.1M65](/packages/php-amqplib-rabbitmq-bundle)[thomasvargiu/rabbitmq-module

Integrates php-amqplib with Zend Framework 2 and RabbitMq

15143.0k1](/packages/thomasvargiu-rabbitmq-module)

PHPackages © 2026

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