PHPackages                             superbalist/laravel4-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. [Framework](/categories/framework)
4. /
5. superbalist/laravel4-event-pubsub

AbandonedArchivedLibrary[Framework](/categories/framework)

superbalist/laravel4-event-pubsub
=================================

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

3.0.2(8y ago)122.9k↓52.7%MITPHPPHP &gt;=5.6.0

Since Jan 30Pushed 3y ago6 watchersCompare

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

READMEChangelog (7)Dependencies (9)Versions (11)Used By (0)

laravel4-event-pubsub
=====================

[](#laravel4-event-pubsub)

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

[![Author](https://camo.githubusercontent.com/abd4e3e2e71081ad01ef09a60c49d70c5e0677497f38918e740703cd02605078/687474703a2f2f696d672e736869656c64732e696f2f62616467652f617574686f722d40737570657262616c6973742d626c75652e7376673f7374796c653d666c61742d737175617265)](https://twitter.com/superbalist)[![Build Status](https://camo.githubusercontent.com/b18cc82914e9154d582a650387213aae49ebc15469e187f4ed7e1237400a596a/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f537570657262616c6973742f6c61726176656c342d6576656e742d7075627375622f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/Superbalist/laravel4-event-pubsub)[![StyleCI](https://camo.githubusercontent.com/428b975752170b9c012caa4cbf64f7429ae17345e688cad132f2c65548b8d665/68747470733a2f2f7374796c6563692e696f2f7265706f732f38303432303432392f736869656c643f6272616e63683d6d6173746572)](https://styleci.io/repos/80420429)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE)[![Packagist Version](https://camo.githubusercontent.com/818029de4e94dda77eecce0df6063fa9a416ed5fa26f1129205e8fb96167bbc7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f737570657262616c6973742f6c61726176656c342d6576656e742d7075627375622e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/superbalist/laravel4-event-pubsub)[![Total Downloads](https://camo.githubusercontent.com/0eb64ea16f477586b224bc4f32819cd32350fa469fbcc02b3edbc30043b05441/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f737570657262616c6973742f6c61726176656c342d6576656e742d7075627375622e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/superbalist/laravel4-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 [laravel4-pubsub](https://github.com/Superbalist/laravel4-pubsub) package adding support for publishing and subscribing to events over pub/sub.

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

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

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

[](#installation)

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

The package has a default configuration built-in.

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

```
php artisan config:publish superbalist/laravel4-event-pubsub
```

You can then edit the generated config at `app/config/packages/superbalist/laravel4-event-pubsub/config.php`.

Register the service provider in app.php

```
'providers' => [
    // ...
    'Superbalist\Laravel4EventPubSub\PubSubEventsServiceProvider',
]
```

Register the facade in app.php

```
'aliases' => [
    // ...
    'PubSubEvents' => 'Superbalist\Laravel4EventPubSub\PubSubEventsFacade',
]
```

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 listen for the following to hook into these:

```
$events = app('events'); // or just use the facade Events

$events->listen('pubsub.events.translation_failure', function ($message) {
    // the message failed to translate into an event
});

$events->listen('pubsub.events.listen_expr_failure', function (\Superbalist\EventPubSub\EventInterface $event, $expr) {
    // the event didn't match the listen expression
    // this isn't really an error, but can be useful for debug
});

$events->listen('pubsub.events.validation_failure', function (\Superbalist\EventPubSub\ValidationResult $result) {
    // the event failed validation
    var_dump($result->errors());
});
```

###  Health Score

34

—

LowBetter than 75% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity27

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

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

Recently: every ~71 days

Total

7

Last Release

3154d ago

Major Versions

1.0.0 → 2.0.02017-02-02

2.0.2 → 3.0.02017-07-17

### Community

Maintainers

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

---

Top Contributors

[![mikefaut](https://avatars.githubusercontent.com/u/30619604?v=4)](https://github.com/mikefaut "mikefaut (17 commits)")[![matthewgoslett](https://avatars.githubusercontent.com/u/1571743?v=4)](https://github.com/matthewgoslett "matthewgoslett (15 commits)")[![shad0wfir3](https://avatars.githubusercontent.com/u/20926935?v=4)](https://github.com/shad0wfir3 "shad0wfir3 (3 commits)")[![johnmarkmassey](https://avatars.githubusercontent.com/u/7905749?v=4)](https://github.com/johnmarkmassey "johnmarkmassey (1 commits)")

---

Tags

event-protocollaravellaravel-packagelaravel4laravel4-event-pubsublaravel4-packagephpphp-event-pubsubphp-pubsubpubsubsuperbalist

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M345](/packages/psalm-plugin-laravel)[laravel/pulse

Laravel Pulse is a real-time application performance monitoring tool and dashboard for your Laravel application.

1.7k15.1M131](/packages/laravel-pulse)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9762.4M131](/packages/roots-acorn)[propaganistas/laravel-disposable-email

Disposable email validator

6023.0M6](/packages/propaganistas-laravel-disposable-email)[illuminate/view

The Illuminate View package.

13047.0M2.2k](/packages/illuminate-view)[mike-bronner/laravel-model-caching

Automatic caching for Eloquent models.

2.4k91.0k1](/packages/mike-bronner-laravel-model-caching)

PHPackages © 2026

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