digiaonline / lumen-sns-middleware
Collection of middleware and helpers for dealing with AWS SNS notifications
Installs: 40 070
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 9
Forks: 3
Open Issues: 0
Requires
- php: >=7.0
- aws/aws-php-sns-message-validator: ^1.4
- digiaonline/json-helpers: ^1.0
- illuminate/http: ^5.5|^6.0
- illuminate/support: ^5.5|^6.0
- jalle19/laravel-lost-interfaces: ^1.2
Requires (Dev)
- phpstan/phpstan: ^0.9.2
- phpunit/phpunit: ^6.4
README
This library contains a collection of middleware and helpers for dealing with AWS SNS notifications.
Features
- a middleware for validating the signatures of SNS notifications
- middleware for transparently handling subscription and unsubscribe confirmations
- a factory for creating SNS
Message
objects from HttpFoundation request objects (which Lumen uses) - a basic enum class for notification types
Requirements
- PHP >= 7.0
- Lumen >= 5.5
Installation
Add the library as a dependency:
composer require digiaonline/lumen-sns-middleware
Register the service provider:
$app->register(Digia\Lumen\SnsMiddleware\Providers\SnsMiddlewareServiceProvider::class);
Usage
Apply any of the following middleware to your routes:
MessageValidatorMiddleware
- validates requests and throws an exception they don't contain a valid SNS messageHandleSubscriptionConfirmationMiddleware
- automatically confirmsSubscriptionConfirmation
messagesHandleUnsubscribeConfirmationMiddleware
- automatically confirmsUnsubscribeConfirmation
messages
Using a custom HTTP client
If for some reason you need to use a custom HTTP client when validating messages or confirming subscription/unsubscribe
messages, bind an implementation of HttpClientInterface
to your container, e.g.:
$app->bind(HttpClientInterface::class, MyImplementation::class);
License
MIT
Testing
Run composer test