PHPackages                             superbalist/laravel-event-pubsub - 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. superbalist/laravel-event-pubsub

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

superbalist/laravel-event-pubsub
================================

An event protocol and implementation over pub/sub for Laravel

3.0.1(8y ago)62.8k2[1 PRs](https://github.com/Superbalist/laravel-event-pubsub/pulls)MITPHPPHP &gt;=5.6.0

Since Jan 30Pushed 3y ago34 watchersCompare

[ Source](https://github.com/Superbalist/laravel-event-pubsub)[ Packagist](https://packagist.org/packages/superbalist/laravel-event-pubsub)[ RSS](/packages/superbalist-laravel-event-pubsub/feed)WikiDiscussions master Synced 2mo ago

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

laravel-event-pubsub
====================

[](#laravel-event-pubsub)

An event protocol and implementation over pub/sub for Laravel.

[![Author](https://camo.githubusercontent.com/abd4e3e2e71081ad01ef09a60c49d70c5e0677497f38918e740703cd02605078/687474703a2f2f696d672e736869656c64732e696f2f62616467652f617574686f722d40737570657262616c6973742d626c75652e7376673f7374796c653d666c61742d737175617265)](https://twitter.com/superbalist)[![Build Status](https://camo.githubusercontent.com/3b4f873e2a417177648bdd870769a9918ad18fd1c0248ff015fe953bb1c01863/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f537570657262616c6973742f6c61726176656c2d6576656e742d7075627375622f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/Superbalist/laravel-event-pubsub)[![StyleCI](https://camo.githubusercontent.com/68c7dd65c4c04f47f989d07a091b371d467deebccf37e281d2caf49a942fea5c/68747470733a2f2f7374796c6563692e696f2f7265706f732f38303430363833302f736869656c643f6272616e63683d6d6173746572)](https://styleci.io/repos/80406830)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE)[![Packagist Version](https://camo.githubusercontent.com/7dbf2ed2b44929eafc8be60f0727308f5b9038683243e4816d43d6f9de56bc3d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f737570657262616c6973742f6c61726176656c2d6576656e742d7075627375622e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/superbalist/laravel-event-pubsub)[![Total Downloads](https://camo.githubusercontent.com/9875af8f3284db557c6a3ecafecdcd5c8495f82f89f741d395e129debbcc27b1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f737570657262616c6973742f6c61726176656c2d6576656e742d7075627375622e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/superbalist/laravel-event-pubsub)

This package is a wrapper bridging [php-event-pubsub](https://github.com/Superbalist/php-event-pubsub) into Laravel. It builds on top of the existing [laravel-pubsub](https://github.com/Superbalist/laravel-pubsub) package adding support for publishing and subscribing to events over pub/sub.

If you aren't familiar with the `laravel-pubsub` package, it's worth first taking a look at their [documentation](https://github.com/Superbalist/laravel-pubsub).

For **Laravel 4** support, use the package

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

[](#installation)

```
composer require superbalist/laravel-event-pubsub
```

The package has a default configuration which uses the following environment variables.

```
PUBSUB_EVENTS_CONNECTION=null
PUBSUB_EVENTS_TRANSLATOR=pubsub.events.translators.simple
PUBSUB_EVENTS_VALIDATOR=null
PUBSUB_EVENTS_THROW_VALIDATION_EXCEPTIONS_ON_DISPATCH=true

```

If the `PUBSUB_EVENTS_CONNECTION` environment variable or `pubsub_events.default` config value is left blank, the default connection will be taken from the `laravel-pubsub` package config.

Register the service provider in app.php

```
'providers' => [
    // ...
    Superbalist\LaravelEventPubSub\PubSubEventsServiceProvider::class,
]
```

Register the facade in app.php

```
'aliases' => [
    // ...
    'PubSubEvents' => Superbalist\LaravelEventPubSub\PubSubEventsFacade::class,
]
```

To customize the configuration file, publish the package configuration using Artisan.

```
php artisan vendor:publish --provider="Superbalist\LaravelEventPubSub\PubSubEventsServiceProvider"
```

You can then edit the generated config at `app/config/pubsub_events.php`.

Usage
-----

[](#usage)

### Simple Events

[](#simple-events)

A `SimpleEvent` is an event which takes a name and optional attributes.

```
// the pubsub_events.translator config setting should be set to 'pubsub.events.translators.simple'

// get the event manager
$manager = app('pubsub.events');

// dispatch an event
$event = new \Superbalist\EventPubSub\Events\SimpleEvent(
    'user.created',
    [
        'user' => [
            'id' => 1456,
            'first_name' => 'Joe',
            'last_name' => 'Soap',
            'email' => 'joe.soap@example.org',
        ],
    ]
);
$manager->dispatch('events', $event);

// dispatch multiple events
$events = [
    new \Superbalist\EventPubSub\Events\SimpleEvent(
        'user.created',
        [
            'user' => [
                // ...
            ],
        ]
    ),
    new \Superbalist\EventPubSub\Events\SimpleEvent(
        'user.created',
        [
            'user' => [
                // ...
            ],
        ]
    ),
];
$manager->dispatchBatch('events', $events);

// listen for an event
$manager->listen('events', 'user.created', function (\Superbalist\EventPubSub\EventInterface $event) {
    var_dump($event->getName());
    var_dump($event->getAttribute('user'));
});

// listen for all events on the channel
$manager->listen('events', '*', function (\Superbalist\EventPubSub\EventInterface $event) {
    var_dump($event->getName());
});

// all the aboce commands can also be done using the facade
PubSubEvents::dispatch('events', $event);
```

### Topic Events

[](#topic-events)

A `TopicEvent` is an event which takes a topic, name, version and optional attributes.

```
// the pubsub_events.translator config setting should be set to 'pubsub.events.translators.topic'

// get the event manager
$manager = app('pubsub.events');

// dispatch an event
$event = new \Superbalist\EventPubSub\Events\TopicEvent(
    'user',
    'created',
    '1.0',
    [
        'user' => [
            'id' => 1456,
            'first_name' => 'Joe',
            'last_name' => 'Soap',
            'email' => 'joe.soap@example.org',
        ],
    ]
);
$manager->dispatch('events', $event);

// listen for an event on a topic
$manager->listen('events', 'user/created', function (\Superbalist\EventPubSub\EventInterface $event) {
    // ...
});

// listen for an event on a topic matching the given version
$manager->listen('events', 'user/created/1.0', function (\Superbalist\EventPubSub\EventInterface $event) {
    // ...
});

// listen for all events on a topic
$manager->listen('events', 'user/*', function (\Superbalist\EventPubSub\EventInterface $event) {
    // ...
});

// listen for all events on the channel
$manager->listen('events', '*', function (\Superbalist\EventPubSub\EventInterface $event) {
    // ...
});
```

### Schema Events

[](#schema-events)

A `SchemaEvent` is an extension of the `TopicEvent` and takes a schema and optional attributes. The topic, name and version are derived from the schema.

The schema must be in the format `(protocol)://(......)?/events/(topic)/(channel)/(version).json`

```
// the pubsub_events.translator config setting should be set to 'pubsub.events.translators.schema'
// the pubsub_events.validator config setting can be set to 'pubsub.events.validators.json_schema' to take advantage of
// JSON Schema validation on incoming events

// get the event manager
$manager = app('pubsub.events');

// dispatch an event
$event = new \Superbalist\EventPubSub\Events\SchemaEvent(
    'http://schemas.my-website.org/events/user/created/1.0.json',
    [
        'user' => [
            'id' => 1456,
            'first_name' => 'Joe',
            'last_name' => 'Soap',
            'email' => 'joe.soap@example.org',
        ],
    ]
);
$manager->dispatch('events', $event);

// the listen expressions are the same as those used for TopicEvents.
```

Error Handling
--------------

[](#error-handling)

The library supports error handlers for when event translation fails, listen expression fails and validation fails.

These are configurable as callables in the translate\_fail\_handler, listen\_expr\_fail\_handler and validation\_fail\_handler config options.

The config contains default callables which will turn the callbacks into Laravel events.

You can register listeners in the EventServiceProvider for the following events:

```
\Superbalist\LaravelEventPubSub\Events\TranslationFailureEvent(
    $message
)

```

```
\Superbalist\LaravelEventPubSub\Events\ListenExprFailureEvent(
    \Superbalist\EventPubSub\EventInterface $event,
    $expr
)

```

```
\Superbalist\LaravelEventPubSub\Events\ValidationFailureEvent(
    \Superbalist\EventPubSub\ValidationResult $result
)

```

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity23

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 86.4% 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 ~44 days

Total

5

Last Release

3213d ago

Major Versions

1.0.0 → 2.0.02017-02-02

2.0.1 → 3.0.02017-07-17

### Community

Maintainers

![](https://www.gravatar.com/avatar/8b8f533cf5a84c29d3860ee32356f0554ead023247638ea952353fc2f01b2e5d?d=identicon)[superbalist](/maintainers/superbalist)

---

Top Contributors

[![matthewgoslett](https://avatars.githubusercontent.com/u/1571743?v=4)](https://github.com/matthewgoslett "matthewgoslett (19 commits)")[![shad0wfir3](https://avatars.githubusercontent.com/u/20926935?v=4)](https://github.com/shad0wfir3 "shad0wfir3 (2 commits)")[![johnmarkmassey](https://avatars.githubusercontent.com/u/7905749?v=4)](https://github.com/johnmarkmassey "johnmarkmassey (1 commits)")

---

Tags

event-protocollaravellaravel-event-pubsublaravel-packagelaravel5laravel5-packagephpphp-event-pubsubphp-pubsubpubsubsuperbalist

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/superbalist-laravel-event-pubsub/health.svg)

```
[![Health](https://phpackages.com/badges/superbalist-laravel-event-pubsub/health.svg)](https://phpackages.com/packages/superbalist-laravel-event-pubsub)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3274.9M308](/packages/psalm-plugin-laravel)[illuminate/pipeline

The Illuminate Pipeline package.

9446.6M213](/packages/illuminate-pipeline)[laragear/preload

Effortlessly make a Preload script for your Laravel application.

119363.5k](/packages/laragear-preload)[flarum/core

Delightfully simple forum software.

211.3M1.9k](/packages/flarum-core)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)[ringierimu/state-workflow

Laravel State Workflow provide tools for defining and managing workflows and activities with ease.

3251.1k](/packages/ringierimu-state-workflow)

PHPackages © 2026

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