Download the PHP package homedoctor-es/laravel-eventbridge-broadcaster without Composer

On this page you can find all versions of the php package homedoctor-es/laravel-eventbridge-broadcaster. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-eventbridge-broadcaster

Laravel EventBridge Broadcaster

Latest Version on Packagist GitHub Workflow Status Total Downloads

The Pub

Similar to Pusher, this package provides Laravel Broadcasting driver for AWS EventBridge in order to publish server-side events.

We understand Broadcasting is usually used to "broadcast" your server-side Laravel Events over a WebSocket connection to your client-side JavaScript application. However, we believe this approach of leveraging broadcasting makes sense for a Pub/Sub architecture where an application would like to broadcast a server-side event to the outside world about something that just happened.

In this context, "channels" can be assimilated to "topics" when using the SNS driver and "event buses" when using the EventBridge driver.

The Sub

This part is not implemented here, but we use this package Laravel EventBridge sqs consumer to consume those events in other of your service.

For this purpose, we're using an architecture like this:

  1. "n" publishers who publish events in EventBridge
  2. Each event is publishes in one SNS topic.
  3. Each one of these topics can be consumed by one or more SQS queues.
  4. Each one of these queues correspond to one app.

Installation

You can install the package on a Laravel 8+ application via composer:

Then, add HomedoctorEs\EventBridgeBroadcaster\EventBridgeBroadcasterServiceProvider::class to load the driver in config/app.php file automatically.

Publishing / Broadcasting

Configuration

You will need to add the following connection and configure your AWS credentials in the config/broadcasting.php configuration file:

Make sure to define your environment variables accordingly:

Next, you will need to make sure you're using the sns broadcast driver as your default driver when broadcasting in your .env file:

Remember that you can define the connection at the Event level if you ever need to be able to use two drivers concurrently.

Usage

Simply follow the default way of broadcasting Laravel events, explained in the official documentation.

In a similar way, you will have to make sure you're implementing the Illuminate\Contracts\Broadcasting\ShouldBroadcast interface and define which channel you'd like to broadcast on.

Broadcast Data

By default, the package will publish the default Laravel payload which is already used when broadcasting an Event. Once published, its JSON representation could look like this:

Using the broadcastWith method, you will be able to define exactly what kind of payload gets published.

Now, when the event is being triggered, it will behave like a standard Laravel event, which means other listeners can listen to it, as usual, but it will also broadcast to the Topic defined by the broadcastOn method using the payload defined by the broadcastWith method.

Broadcast Name / Subject

In a Pub/Sub context, it can be handy to specify a Subject on each notification which broadcast to SNS. This can be an easy way to configure a Listeners for each specific kind of subject you can receive and process later on within queues.

By default, the package will use the standard Laravel broadcast name in order to define the Subject of the notification sent. Feel free to customize it as you wish.

Model Broadcasting

If you're familiar with Model Broadcasting, you already know that Eloquent models dispatch several events during their lifecycle and broadcast them accordingly.

In the context of model broadcasting, only the following model events can be broadcasted:

In order to broadcast the model events, you need to use the Illuminate\Database\Eloquent\BroadcastsEvents trait on your Model and follow the official documentation.

You can use broadcastOn(), broadcastWith() and broadcastAs() methods on your model in order to customize the Topic names, the payload and the Subject respectively.

Note: Model Broadcasting is only available from Laravel 8.x.

Credits

License

The MIT License (MIT). Please see License File for more information.


All versions of laravel-eventbridge-broadcaster with dependencies

PHP Build Version
Package Version
Requires php Version ^7.3|^8.0
ext-json Version *
aws/aws-sdk-php Version ^3.155
illuminate/support Version ^8.52|^9.0|^10.0|^11.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package homedoctor-es/laravel-eventbridge-broadcaster contains the following files

Loading the files please wait ....