PHPackages                             jimphle/messaging - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. jimphle/messaging

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

jimphle/messaging
=================

Jimdo PHP library extraction of messaging component

v1.2.1(8y ago)5782[1 issues](https://github.com/Jimdo/jimphle-messaging/issues)[1 PRs](https://github.com/Jimdo/jimphle-messaging/pulls)MITPHPPHP &gt;=5.6.0CI passing

Since Apr 15Pushed 2d ago111 watchersCompare

[ Source](https://github.com/Jimdo/jimphle-messaging)[ Packagist](https://packagist.org/packages/jimphle/messaging)[ Docs](https://github.com/Jimdo/jimphle-messaging)[ RSS](/packages/jimphle-messaging/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (2)Dependencies (5)Versions (19)Used By (0)

Jimphle-messaging
=================

[](#jimphle-messaging)

Jimdo PHP library extraction of messaging component.

The Messaging component is base on message-handler which implement the MessageHandler Interface.

Handling commands and events
----------------------------

[](#handling-commands-and-events)

Let's get started with sending a command say-hello:

```
use Jimphle\Example\MessageHandler\SayHelloHandler;

use Jimphle\Messaging\MessageHandler\HandleMessage;
use Jimphle\Messaging\MessageHandlerProvider;
use Jimphle\Messaging\Command;

$messageHandlerDefinitions = array(
    'say-hello' => new SayHelloHandler(),
);
$messagingContext = new HandleMessage(
    new MessageHandlerProvider(
        new ArrayObject(
            $messageHandlerDefinitions
        )
    )
);

$response = $messagingContext->handle(
    Command::generate(
        'say-hello',
        array(
            'name' => 'World'
        )
    )
);
echo $response->answer;

# => Hello World!
```

Ok what happened here? We passed the Command say-hello and it's payload to the messagingContext. The messagingContext did a lookup for A MessageHandler registered to say-hello.

Something more interesting. If you had a look at the SayHelloHandler you would have seen that the handler itself generated a new Event which is returned with the MessageResponse "to-be-processed-directly" by the calling context. To make our messagingContext to be able to handle this kind of messages we have to add another kind of handler.

```
use Jimphle\Example\MessageHandler\BeObsceneHandler;
use Jimphle\Example\MessageHandler\SayHelloHandler;

use Jimphle\Messaging\MessageHandler\HandleMessagesToProcessDirectly;
use Jimphle\Messaging\MessageHandler\HandleMessage;
use Jimphle\Messaging\MessageHandlerProvider;
use Jimphle\Messaging\Command;

$messageHandlerDefinitions = array(
    'say-hello' => new SayHelloHandler(),
    'said-hello' => array(
        new BeObsceneHandler()
    )
);
$messagingContext = new HandleMessagesToProcessDirectly(
    new HandleMessage(
        new MessageHandlerProvider(
            new ArrayObject(
                $messageHandlerDefinitions
            )
        )
    )
);

$response = $messagingContext->handle(
    Command::generate(
        'say-hello',
        array(
            'name' => 'World'
        )
    )
);
echo $response->answer . "\n";

# => GTFO Joscha!
# => Hello World!
```

As you can see Our said-hello Event is handled by the messagingContext now. Which means the messagingContext handles the SayHelloHandler iterates over the returned "to-be-processed-directly" events and tries to handle them as well. How you may have noticed the order of the printed messages is reversed to the order the printing handlers are called. This happens because the response of the first called message-handler is the one which is returned here.

Message-filter and message-handler annotations
----------------------------------------------

[](#message-filter-and-message-handler-annotations)

If you add the ApplyFilter MessageHandler to the messagingContext you add the possibility to apply filter to a message before passing it to the next message-handler.

```
$messageFilterDefinitions = array(new SomeMessageFilter());
$messagingContext = new HandleMessagesToProcessDirectly(
    new ApplyFilter(
        $messageFilterDefinitions,
        new HandleMessage(
            new MessageHandlerProvider(
                new ArrayObject(
                    $messageHandlerDefinitions
                )
            )
        )
    )
);
```

However there are two predefined filter we can use here:

- The Validation filter, based on Symfony-Validation-Component
- The Authorization filter explained here another day

Handling messages in a PDO transaction
--------------------------------------

[](#handling-messages-in-a-pdo-transaction)

To handle the messages in a PDO transaction we can add the TransactionalMessageHandler to the messagingContext.

```
$messagingContext = new HandleMessagesToProcessDirectly(
    new TransactionalMessageHandler(
        new PDO('some-dsn'),
        new ApplyFilter(
            $messageFilterDefinitions,
            new HandleMessage(
                new MessageHandlerProvider(
                    new ArrayObject(
                        $messageHandlerDefinitions
                    )
                )
            )
        )
    )
);
```

To execute a message handler in a pdo transaction you just have to add an annotation.

```
use Jimphle\Messaging\Plugin\Pdo\TransactionalAnnotation as withPdoTransaction;

/**
 * @withPdoTransaction
 */
class SayHelloHandler extends AbstractMessageHandler
{
    public function handle(Message $message)
    {
        return $this->response(
            array('answer' => sprintf("Hello %s!", $message->name))
        )
            ->addMessageToProcessDirectly(
                $this->event('said-hello', array('name' => 'Joscha'))
            );
    }
}
```

###  Health Score

43

—

FairBetter than 91% of packages

Maintenance61

Regular maintenance activity

Popularity15

Limited adoption so far

Community22

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 76.6% 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 ~76 days

Recently: every ~184 days

Total

17

Last Release

3186d ago

Major Versions

v0.5.0 → v1.0.02016-06-21

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

v1.2.0PHP &gt;=5.6.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/4967f42f1b5fc14752d411300fc634ffee7aa79da30abcafe8750d4f755a3295?d=identicon)[schnipseljagd](/maintainers/schnipseljagd)

---

Top Contributors

[![schnipseljagd](https://avatars.githubusercontent.com/u/289073?v=4)](https://github.com/schnipseljagd "schnipseljagd (36 commits)")[![MorrisJobke](https://avatars.githubusercontent.com/u/245432?v=4)](https://github.com/MorrisJobke "MorrisJobke (4 commits)")[![Pkharmat](https://avatars.githubusercontent.com/u/4611887?v=4)](https://github.com/Pkharmat "Pkharmat (3 commits)")[![desouradeep](https://avatars.githubusercontent.com/u/1932760?v=4)](https://github.com/desouradeep "desouradeep (2 commits)")[![Partyschaum](https://avatars.githubusercontent.com/u/626843?v=4)](https://github.com/Partyschaum "Partyschaum (1 commits)")[![tobias-jimdo](https://avatars.githubusercontent.com/u/864678?v=4)](https://github.com/tobias-jimdo "tobias-jimdo (1 commits)")

---

Tags

owner-team-creatormessagingevent handlercommand handlermessage-handler

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/jimphle-messaging/health.svg)

```
[![Health](https://phpackages.com/badges/jimphle-messaging/health.svg)](https://phpackages.com/packages/jimphle-messaging)
```

###  Alternatives

[jcbrand/converse.js

Browser based XMPP instant messaging client

3.2k156.6k](/packages/jcbrand-conversejs)[musonza/chat

Chat Package for Laravel

1.2k253.4k1](/packages/musonza-chat)[prooph/service-bus

PHP Enterprise Service Bus Implementation supporting CQRS and DDD

4421.4M32](/packages/prooph-service-bus)[jobcloud/php-kafka-lib

Jobcloud PHP Kafka library

58560.6k3](/packages/jobcloud-php-kafka-lib)[fof/byobu

Well integrated, advanced private discussions.

61105.8k9](/packages/fof-byobu)[lexxyungcarter/chatmessenger

Simple one-to-one/group chat messaging tool for Laravel 5, 6, 7, 8, 9 &amp; 10 with Pusher Integration

10724.1k](/packages/lexxyungcarter-chatmessenger)

PHPackages © 2026

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