| Package Data | |
|---|---|
| Maintainer Username: | rennokki | 
| Maintainer Contact: | alex@renoki.org (Alex Renoki) | 
| Package Create Date: | 2019-05-29 | 
| Package Last Update: | 2025-09-29 | 
| Home Page: | |
| Language: | PHP | 
| License: | Apache-2.0 | 
| Last Refreshed: | 2025-10-27 03:18:51 | 
| Package Statistics | |
|---|---|
| Total Downloads: | 704,956 | 
| Monthly Downloads: | 5,881 | 
| Daily Downloads: | 54 | 
| Total Stars: | 133 | 
| Total Watchers: | 1 | 
| Total Forks: | 20 | 
| Total Open Issues: | 4 | 
Laravel SNS Events allow you to listen to SNS webhooks via Laravel Events. It implements a controller that is made to properly listen to SNS HTTP(s) webhooks and trigger events on which you can listen to in Laravel.
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.
$ composer require rennokki/laravel-sns-events
The package comes with two event classes:
Rennokki\LaravelSnsEvents\Events\SnsEvent - triggered on each SNS messageRennokki\LaravelSnsEvents\Events\SnsSubscriptionConfirmation - triggered when the subscription is confirmedThis package comes with a controller that will handle the response for you. Register the route in your web.php:
...
// you can choose any route
Route::any('/aws/sns', 'Rennokki\LaravelSnsEvents\Http\Controllers\SnsController@handle');
SNS sends data through POST, so you will need to whitelist your route in your VerifyCsrfToken.php:
protected $except = [
    ...
    'aws/sns/',
];
You will need an AWS account and register a SNS Topic and set up a subscription for HTTP(s) protocol that will point out to the route you just registered.
If you have registered the route and created a SNS Topic, you should register the URL and 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.
To process the events, you should add the events in your app/Providers/EventServiceProvider.php:
use Rennokki\LaravelSnsEvents\Events\SnsEvent;
use Rennokki\LaravelSnsEvents\Events\SnsSubscriptionConfirmation;
...
protected $listen = [
    ...
    SnsEvent::class => [
        // add your listeners here for SNS events
    ],
    SnsSubscriptionConfirmation::class => [
        // add your listeners here in case you want to listen to subscription confirmation
    ],
]
You will be able to access the SNS message from your listeners like this:
class MyListener
{
    ...
    public function handle($event)
    {
        // $event->message is an array
    }
}
For example, synthetizing an AWS Polly Text-To-Speech would return in $event->message an array like this:
[
    'taskId' => '...',
    'taskStatus' => 'FAILED',
    'taskStatusReason' => 'Error occurred while trying to upload file to S3. Please verify that the bucket existsin this region and you have permission to write objects to the specified bucket.',
    'outputUri' => 's3://...',
    'creationTime' => '2019-05-29T15:27:31.231Z',
    'requestCharacters' => 58,
    'snsTopicArn' => '...',
    'outputFormat' => 'Mp3',
    'sampleRate' => '22050',
    'speechMarkTypes' => [],
    'textType' => 'Text',
    'voiceId' => 'Joanna',
]
Run the tests with:
vendor/bin/phpunit
Please see CHANGELOG for more information what has changed recently.
Please see CONTRIBUTING for details.
If you discover any security-related issues, please email DummyAuthorEmail instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.