Download the PHP package ringierimu/event-bus without Composer
On this page you can find all versions of the php package ringierimu/event-bus. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download ringierimu/event-bus
More information about ringierimu/event-bus
Files in ringierimu/event-bus
Informations about the package event-bus
Laravel Event Bus
Introduction
Laravel Event Bus provides a simple interface that provides a Laravel event the ability to be dispatched onto Ringier Event Bus.
Installation
Install the package using composer:
Next publish the config file using:
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:
You are encouraged to have a further look at the config/event-bus.php
file to learn more about other available configurations.
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.
Finally, just dispatch you event as you would any normal Laravel event. Your event will now be dispatched onto the bus.
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:
You may also implement a broadcastToEventBusAs
method on your Laravel Event class, however note that withEventType
will
take precedence over broadcastToEventBusAs
.
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
:
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.
Testing
All versions of event-bus with dependencies
guzzlehttp/guzzle Version ^7.4
illuminate/contracts Version ^8.0|^9.0|^10.0
illuminate/support Version ^8.0|^9.0|^10.0