Download the PHP package bridit/laravel-sns without Composer
On this page you can find all versions of the php package bridit/laravel-sns. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package laravel-sns
Laravel SNS
Laravel SNS allow you to broadcast and listen to SNS events.
It implements a driver on BroadcastManager to make the use of SNS as easy as Laravel Events.
It also implements a controller, using rennokki/laravel-sns-events
package, that is made to properly listen to SNS HTTP(s) webhooks and trigger events on which you can listen to.
If you are not familiar with Laravel Events & Listeners, make sure you check the documentation section on laravel.com because this package will need you to understand this concept.
Make sure to also check rennokki/laravel-sns-events
documentation.
Install
Configuration
You will need an AWS account and make sure you have it properly configured on Laravel, following the steps of official documentation.
Then you need to register a connection for SNS on broadcasting.php, you can do this adding code above on connections section of broadcasting.php:
We made use of env variables to build arn_prefix, but you can also specify a simple string. You can find your arn on AWS platform, on any topic you own.
This package auto register the necessary routes for you, on web middleware, using 'route' attribute of broadcasting.php. You don't need to do it by yourself.
SNS sends data through POST, so you will need to whitelist your route in your VerifyCsrfToken.php
:
If you want this to be your default broadcasting driver set it on your .env:
Now you are ready to go. Just create a topic and set up a subscription for HTTP(s) protocol that will point out to the route you just registered. Click the confirmation button from the AWS Dashboard. In a short while, if you implemented the route well, you'll be seeing that your endpoint is registered.
Usage
To send SNS events just use default Laravel dispatcher, like:
The package comes with two event classes:
Rennokki\LaravelSnsEvents\Events\SnsNotification
- triggered on each SNS messageRennokki\LaravelSnsEvents\Events\SnsSubscriptionConfirmation
- triggered when the subscription is confirmed
To process the events, you should add the events in your app/Providers/EventServiceProvider.php
:
You will be able to access the SNS message from your listeners like this:
License
The MIT License (MIT).
All versions of laravel-sns with dependencies
aws/aws-sdk-php-laravel Version ^3.0
illuminate/broadcasting Version ^5.8|^6.0|^7.0|^8.0|^9.0
illuminate/support Version ^5.8|^6.0|^7.0|^8.0|^9.0
rennokki/laravel-sns-events Version ^7.0