PHPackages                             mamuz/message-bridge - 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. mamuz/message-bridge

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

mamuz/message-bridge
====================

Message bridge to support a decoupled event driven and aspect oriented application

v1.0.0(9y ago)422.3kMITPHP ^7.0

Since Sep 12Compare

[ Source](https://github.com/mamuz/message-bridge)[ Packagist](https://packagist.org/packages/mamuz/message-bridge)[ Docs](https://github.com/mamuz/message-bridge)[ RSS](/packages/mamuz-message-bridge/feed)WikiDiscussions Synced today

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

Message Bridge
==============

[](#message-bridge)

[![Author](https://camo.githubusercontent.com/e49859db77ebe675300539af2d01c10b7568b92df2dbbd190335170cd198e5fa/687474703a2f2f696d672e736869656c64732e696f2f62616467652f617574686f722d406d616d757a5f64652d626c75652e7376673f7374796c653d666c61742d737175617265)](https://twitter.com/mamuz_de)[![Build Status](https://camo.githubusercontent.com/6e04de4c275a5c96b4b5ff771b160ff1bcc1871bb90f3e825f56f59a30412344/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f6d616d757a2f6d6573736167652d6272696467652e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/mamuz/message-bridge)[![Latest Stable Version](https://camo.githubusercontent.com/662fdeba03a7eaa32199431d3cfc6d28639082ddeb1979666f7fd5c139d9f34a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d616d757a2f6d6573736167652d6272696467652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/mamuz/message-bridge)[![Total Downloads](https://camo.githubusercontent.com/f5ac3dc71d0c199bd7d924668a8750777822b7043336a369497eb2ad4c18c0b9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d616d757a2f6d6573736167652d6272696467652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/mamuz/message-bridge)[![License](https://camo.githubusercontent.com/0f70f07815e01ee78920f4aa65dde7a1ab6068197c2ac3cc3e3bc0903aaf4082/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6d616d757a2f6d6573736167652d6272696467652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/mamuz/message-bridge)

Message Bridge let you trigger messages from anywhere in a procedural or in an object-oriented way. A registered callback can dispatch or forward all triggered messages. Main idea is to support a decoupled event driven and aspect oriented application, thus object awareness to any logger or any event dispatcher is not needed anymore.

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

[](#installation)

Install the latest version with

```
$ composer require mamuz/message-bridge
```

Example
-------

[](#example)

### Procedural

[](#procedural)

```
// Register dispatch callback globally
set_message_dispatcher(function ($msg, $argv, $emitter) {
    if ($msg == 'user.registered') {
        mail('foo@bar.com', 'A new user entered', 'UserId ' . $argv['userId']);
    }
});

// Trigger any message anywhere
trigger_message('user.registered', array('userId' => 1234));
```

### Object oriented way with forwarding

[](#object-oriented-way-with-forwarding)

```
$bridge = \MsgBridge\MessageBridge::getInstance();
$bridge->bindDispatcher(function ($msg, $argv, $emitter) use ($eventManager) {
    $eventManager->trigger($msg, $argv, $emitter);
});

// ...

$bridge->trigger('user.registered', array('userId' => 1234));
```

Locking concept and Test Isolation
----------------------------------

[](#locking-concept-and-test-isolation)

To prevent side-effects the dispatcher can be registered with write protection.

```
$locked = true;
set_message_dispatcher($closure, $locked);

// This will throw a RuntimeException now
set_message_dispatcher($anotherClosure);
```

In Unit Tests you should not register a dispatcher with write protection, otherwise test isolation is not given. Instead of that implement following snippet to the tearDown method.

```
public function tearDown()
{
    \MsgBridge\MessageBridge::getInstance()->unsetDispatcher();
}
```

As an alternative you can add the provided TestListener to your phpunit.xml. This Listener will do the job for you automaticly.

```

```

###  Health Score

32

—

LowBetter than 69% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity27

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity62

Established project with proven stability

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

Total

5

Last Release

3566d ago

Major Versions

v0.3.1 → v1.0.02016-09-27

PHP version history (2 changes)v0.1.0PHP &gt;=5.4

v1.0.0PHP ^7.0

### Community

Maintainers

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

---

Tags

messageeventaopBridge

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/mamuz-message-bridge/health.svg)

```
[![Health](https://phpackages.com/badges/mamuz-message-bridge/health.svg)](https://phpackages.com/packages/mamuz-message-bridge)
```

###  Alternatives

[php-amqplib/php-amqplib

Formerly videlalvaro/php-amqplib. This library is a pure PHP implementation of the AMQP protocol. It's been tested against RabbitMQ.

4.6k132.3M1.0k](/packages/php-amqplib-php-amqplib)[amphp/amp

A non-blocking concurrency framework for PHP applications.

4.4k133.8M434](/packages/amphp-amp)[revolt/event-loop

Rock-solid event loop for concurrent PHP applications.

92553.8M226](/packages/revolt-event-loop)[php-amqplib/rabbitmq-bundle

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

1.3k20.9M69](/packages/php-amqplib-rabbitmq-bundle)[aws/aws-php-sns-message-validator

Amazon SNS message validation for PHP

22223.4M118](/packages/aws-aws-php-sns-message-validator)[fotografde/cakephp-sms

SMS Plugin for CakePHP

1473.2k](/packages/fotografde-cakephp-sms)

PHPackages © 2026

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