This library contains a collection of middleware and helpers for dealing with AWS SNS notifications.
- 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
- PHP >= 7.0
- Lumen >= 5.5
Add the library as a dependency:
composer require digiaonline/lumen-sns-middleware
Register the service provider:
$app->register(Digia\Lumen\SnsMiddleware\Providers\SnsMiddlewareServiceProvider::class);
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
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);
MIT
Run composer test