PHPackages                             jsonbaby/event-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. jsonbaby/event-bridge

ActiveLibrary

jsonbaby/event-bridge
=====================

014PHP

Since Jul 9Pushed 3y ago1 watchersCompare

[ Source](https://github.com/akabuda050/event-bridge)[ Packagist](https://packagist.org/packages/jsonbaby/event-bridge)[ RSS](/packages/jsonbaby-event-bridge/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Very short description of the package
=====================================

[](#very-short-description-of-the-package)

This package provides basic interfaces for event publishing and subscribing to it. Redis is used out of the box.

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

[](#installation)

`composer require jsonbaby/event-bridge`

`php artisan event-bridge:install`

Usage
-----

[](#usage)

In order to get this work you should have a centralized store of your events(package, repository, etc), so you can use it between your applications.(for communication between multiple apps).

All events should implement `JsonBaby\EventBase\Interfaces\EventInterface` from [EventBase package](https://packagist.org/packages/jsonbaby/events-base "EventBase package")Events will be handled by an event handler that takes listeners from `config/event-bridge.php`. So you can add your listeners to config. This is very similar to adding laravel one.

This `config/event-bridge.php` contains other configs required by `EventBridgeServiceProvider` in case you want to build your own things based on contracts defined in this package.

**NOTE:** if you will use this package for multiple applications should have the same classes of events and serializers, etc in order to have correct communication. For example: you can not use `XmlSerializer` for serialization in app1 and `JsonSerializer` in app2 for deserialization. So if you want to build your own stuff based on this package you can fork this one, add things and use your package in your apps instead of this one. If you will not use it for multiple apps, feel free to create your own implementation in your project directory without forking.

Example single app
------------------

[](#example-single-app)

Out of the box we use Redis in order to publish and subscribe. So you need to setup Redis in your app as well.

- Install package `composer require jsonbaby/event-bridge`
- Add an event and listener somewhere in your app

    ```
    namespace App\Events;

    use DateTimeImmutable;
    use JsonBaby\EventBase\Interfaces\EventInterface;

    final class AcmeEvent implements EventInterface
    {
        public function __construct(
            private DateTimeImmutable $at,
            private string $acmeProperty,
        ) {
        }

        public static function getType(): string
        {
            return 'acme-event';
        }

        public function getAt(): DateTimeImmutable
        {
            return $this->at;
        }

        public function getAcmeProperty(): string
        {
            return $this->acmeProperty;
        }

        public function getData(): array
        {
            return [
                'at' => $this->getAt(),
                'acme_property' => $this->getAcmeProperty()
            ];
        }
    }

    --------

    namespace App\Events;

    class AcmeEventListener
    {
        public function handle(AcmeEvent $event) // AcmeEvent should implement JsonBaby\EventBase\Interfaces\EventInterface
        {
            // deal with AcmeEvent
            $data = $event->getData();
            ...
        }
    }
    ```
- Add the event listener to `config/event-bridge.php`

    ```
    'listeners' => [
        AcmeEvent::class => [
            AcmeEventListener::class
        ]
    ]
    ```
- Publish your event

    ```
    use App\Events\AcmeEvent;

    app()->make(EventPubSubInterface::class)->publish('acme-channel', new AcmeEvent(new DateTimeImmutable(), 'acme_property'));
    ```
- Create artisan command and subscribe to a channel in it using snippet bellow.

    ```
    app()->make(EventPubSubInterface::class)->subscribe(['acme-channel']);
    ```

Example multi apps
------------------

[](#example-multi-apps)

Out of the box we use Redis in order to publish and subscribe. So you need to setup Redis(should be shared between all apps) in your apps as well.

- App 1

    - Install package `composer require jsonbaby/event-bridge`
    - Add your centralized events package to project like `composer require foo/bar-events` or as `git` package
    - Publish your event

        ```
        use Foo\Bar\AcmeEvent;

        app()->make(EventPubSubInterface::class)->publish('acme-channel', new AcmeEvent(new DateTimeImmutable(), 'acme_property'));
        ```
- App 2

    - Install package `composer require jsonbaby/event-bridge`
    - Add your centralized events package to project like `composer require foo/bar-events` or as `git` package
    - Create an event listener somewhere in your app

        ```
        namespace App\CrossAppEvents;

        use Foo\Bar\AcmeEvent;

        class AcmeEventListener
        {
            public function handle(AcmeEvent $event) // AcmeEvent should implement JsonBaby\EventBase\Interfaces\EventInterface
            {
                // deal with AcmeEvent
                $data = $event->getData();
                ...
            }
        }
        ```
    - Add the event listener to `config/event-bridge.php`

        ```
        'listeners' => [
            AcmeEvent::class => [
                AcmeEventListener::class
            ]
        ]
        ```
    - Create artisan command and subscribe to a channel in it using snippet bellow.

        ```
        app()->make(EventPubSubInterface::class)->subscribe(['acme-channel']);
        ```

###  Health Score

15

—

LowBetter than 3% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity25

Early-stage or recently created project

 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.

### Community

Maintainers

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

---

Top Contributors

[![akabuda050](https://avatars.githubusercontent.com/u/9349169?v=4)](https://github.com/akabuda050 "akabuda050 (24 commits)")

### Embed Badge

![Health badge](/badges/jsonbaby-event-bridge/health.svg)

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

PHPackages © 2026

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