PHPackages                             ringierimu/event-bus - 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. ringierimu/event-bus

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

ringierimu/event-bus
====================

Send Laravel Events to Event Bus

1.0.0(2y ago)25.5k1MITPHPPHP ^8.0

Since Apr 8Pushed 2y ago18 watchersCompare

[ Source](https://github.com/RingierIMU/laravel-event-bus)[ Packagist](https://packagist.org/packages/ringierimu/event-bus)[ RSS](/packages/ringierimu-event-bus/feed)WikiDiscussions main Synced 4w ago

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

 Laravel Event Bus
-------------------

[](#----laravel-event-bus)

[![Build Status](https://github.com/RingierIMU/laravel-event-bus/workflows/Quality/badge.svg)](https://github.com/RingierIMU/laravel-event-bus/actions)[![StyleCI](https://camo.githubusercontent.com/43bd4940b70db0be02907ecf165c6d4c723848793c4ebc91121c6ec3c22471a3/68747470733a2f2f6769746875622e7374796c6563692e696f2f7265706f732f3432373234383037372f736869656c643f6272616e63683d6d61696e)](https://github.styleci.io/repos/427248077?branch=main)[![Total Downloads](https://camo.githubusercontent.com/6aa5aed801907fdfa673b9f3a3fc56e86df1d713ad2e1f8241f81947f7224cfe/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f72696e67696572696d752f6576656e742d627573)](https://packagist.org/packages/ringierimu/event-bus)[![Latest Stable Version](https://camo.githubusercontent.com/3c979cbfeea9386de38ba046d46a4fa8c9c8b4045a3bffda769333cbd89bd153/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f72696e67696572696d752f6576656e742d627573)](https://packagist.org/packages/ringierimu/event-bus)[![License](https://camo.githubusercontent.com/b6552e250606b048d75d10f0ad5af3bf515ded0202b918333d46fb78c2f31f2f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f72696e67696572696d752f6576656e742d627573)](https://packagist.org/packages/ringierimu/event-bus)

Introduction
------------

[](#introduction)

Laravel Event Bus provides a simple interface that provides a Laravel event the ability to be dispatched onto [Ringier Event Bus](https://docs.bus.ritdu.net/).

### Installation

[](#installation)

Install the package using composer:

```
composer require ringierimu/event-bus
```

Next publish the config file using:

```
php artisan vendor:publish --provider=Ringierimu\EventBus\EventBusServiceProvider
```

This will create a config file at `config/event-bus.php`. Feel free to browse the file and update it as required by your application.

Update your `.env` file with the following variable substitution the correct values for your application:

```
RINGIER_SB_NODE_ID=123456789
RINGIER_SB_USER=event_bus_user
RINGIER_SB_PASSWORD=event_bus_password
```

You are encouraged to have a further look at the `config/event-bus.php` file to learn more about other available configurations.

### Usage

[](#usage)

To make a Laravel Event dispatchable onto the bus you only need to have your event class extend the `Ringierimu\EventBus\Contracts\ShouldBroadcastToEventBus` interface. You then need to implement the `toEventBus` method on the Event class; this will allow you to configure how the event will be sent to the bus as. E.g payload, eventType, action and so on.

```
namespace App\Events

use App\Models\Listing;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;
use Ringierimu\EventBus\Contracts\ShouldBroadcastToEventBus;
use Ringierimu\EventBus\Event;

class ListingCreatedEvent implements ShouldBroadcastToEventBus
{
    use Dispatchable, SerializesModels;

    /**
     * Create an instance of ListingCreated event.
     *
     * @param  Listing  $listing
     */
    public function __construct(
        public Listing $listing
    ) {
    }

    /**
     * Get the representation of the event for the EventBus.
     *
     * @param  Event  $event
     * @return Event
     */
    public function toEventBus(Event $event): Event
    {
        return $event
            ->withPayload([
                'id' => $this->listing->id,
                'title' => $this->listing->title,
                'description' => $this->listing->description
            ]);
    }
}
```

Finally, just dispatch you event as you would any normal Laravel event. Your event will now be dispatched onto the bus.

```
namespace App\Http\Controllers;

use App\Events\ListingCreatedEvent;
use App\Http\Requests\StoreListingRequest;
use App\Models\Listing;
use Illuminate\Http\RedirectResponse;

class ListingController extends Controller
{
    /**
     * Store a new Listing.
     *
     * @return RedirectResponse
     */
    public function store(StoreListingRequest $request): RedirectResponse
    {
        $listing = Listing::create($request->validated());

        // Event will automatically be dispatched onto the
        // bus as well.
        ListingCreatedEvent::dispatch($listing);

        return back();
    }
}
```

### Customising the Event type

[](#customising-the-event-type)

By default, event type is being sent as the name of the event class. However, you can customise the type name by using the `withEventType` method of the `Ringierimu\EventBus\Event` class. In your `toEventBus` method do the following:

```
/**
 * Get the representation of the event for the EventBus.
 *
 * @param  Event  $event
 * @return Event
 */
public function toEventBus(Event $event): Event
{
    return $event
        ->withEventType('UserListingCreatedEvent')
        ->withPayload([
            'id' => $this->listing->id,
            'title' => $this->listing->title,
            'description' => $this->listing->description
        ]);
}
```

You may also implement a `broadcastToEventBusAs` method on your Laravel Event class, however note that `withEventType` will take precedence over `broadcastToEventBusAs`.

```
namespace App\Events

use App\Models\Listing;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;
use Ringierimu\EventBus\Contracts\ShouldBroadcastToEventBus;
use Ringierimu\EventBus\Event;

class ListingCreatedEvent implements ShouldBroadcastToEventBus
{
    use Dispatchable, SerializesModels;

    /**
     * Create an instance of ListingCreated event.
     *
     * @param  Listing  $listing
     */
    public function __construct(
        public Listing $listing
    ) {
    }

    /**
     * Get the representation of the event for the EventBus.
     *
     * @param  Event  $event
     * @return Event
     */
    public function toEventBus(Event $event): Event
    {
        return $event
            ->withPayload([
                'id' => $this->listing->id,
                'title' => $this->listing->title,
                'description' => $this->listing->description
            ]);
    }

    /**
     * Get the event type name being sent to the event bus.
     *
     * @return string
     */
    public function broadcastToEventBusAs(): string
    {
        return 'UserListingCreatedEvent';
    }
}
```

### Customising the queue

[](#customising-the-queue)

By default, all event bus events being sent are processed on queue. Your default queue and connection will be used for sending dispatching the jobs, however you can specify a dedicated queue and connection for processing your events by adding the following to your `.env`:

```
RINGIER_SB_QUEUE=eventbus
RINGIER_SB_QUEUE_CONNECTION=redis
```

Alternatively you can specify the queue and connection on a per-Event basis by adding the `onQueue` and `onConnection` methods to your Laravel Event classes.

```
namespace App\Events

use App\Models\Listing;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;
use Ringierimu\EventBus\Contracts\ShouldBroadcastToEventBus;
use Ringierimu\EventBus\Event;

class ListingCreatedEvent implements ShouldBroadcastToEventBus
{
    use Dispatchable, SerializesModels;

    /**
     * Create an instance of ListingCreated event.
     *
     * @param  Listing  $listing
     */
    public function __construct(
        public Listing $listing
    ) {
    }

    /**
     * Get the representation of the event for the EventBus.
     *
     * @param  Event  $event
     * @return Event
     */
    public function toEventBus(Event $event): Event
    {
        return $event
            ->withPayload([
                'id' => $this->listing->id,
                'title' => $this->listing->title,
                'description' => $this->listing->description
            ]);
    }

    /**
     * Specify the queue name on which this event should be processed.
     *
     * @param  Event  $event
     * @return string
     */
    public function onQueue(Event $event): string
    {
        return 'eventbus';
    }

    /**
     * Specify the queue connection on which this event should be processed.
     *
     * @param  Event  $event
     * @return string
     */
    public function onConnection(Event $event): string
    {
        return 'redis';
    }
}
```

### Testing

[](#testing)

```
phpunit
```

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community18

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 66.7% 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 ~82 days

Recently: every ~123 days

Total

7

Last Release

998d ago

Major Versions

0.1.2 → 1.0.02023-08-15

### Community

Maintainers

![](https://www.gravatar.com/avatar/85cb9b6b5d2c5f9d780815d68a22d6accb686a7c606b83b170a846e9a9a1ac08?d=identicon)[matthewnessworthy](/maintainers/matthewnessworthy)

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

![](https://www.gravatar.com/avatar/19dab64f7dbbf796f1cdc371109ed107e37656422b4bf2bac712c1aa6262fb90?d=identicon)[rimu](/maintainers/rimu)

![](https://www.gravatar.com/avatar/3db0a14dead2c0a8eec8526b1cfa43aabff2e4cde044fefb9d4ddccb0fbc8128?d=identicon)[percymamedy](/maintainers/percymamedy)

---

Top Contributors

[![percymamedy](https://avatars.githubusercontent.com/u/11259669?v=4)](https://github.com/percymamedy "percymamedy (8 commits)")[![datashaman](https://avatars.githubusercontent.com/u/59514?v=4)](https://github.com/datashaman "datashaman (2 commits)")[![matthewnessworthy](https://avatars.githubusercontent.com/u/5653887?v=4)](https://github.com/matthewnessworthy "matthewnessworthy (2 commits)")

---

Tags

laraveleventsservicebus

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/ringierimu-event-bus/health.svg)

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

###  Alternatives

[laravel/socialite

Laravel wrapper around OAuth 1 &amp; OAuth 2 libraries.

5.7k96.9M672](/packages/laravel-socialite)[spatie/laravel-health

Monitor the health of a Laravel application

85810.0M83](/packages/spatie-laravel-health)[harris21/laravel-fuse

Circuit breaker for Laravel queue jobs. Protect your workers from cascading failures.

3786.5k](/packages/harris21-laravel-fuse)[bensampo/laravel-embed

Painless responsive embeds for videos, slideshows and more.

142146.8k](/packages/bensampo-laravel-embed)[truckersmp/steam-socialite

Laravel Socialite provider for Steam OpenID.

1516.7k](/packages/truckersmp-steam-socialite)[roomies/phonable

Gather insights and verify phone numbers from multiple third-party providers.

123.5k](/packages/roomies-phonable)

PHPackages © 2026

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