Collection of middleware and helpers for dealing with AWS SNS notifications
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
tests
.gitignore
.travis.yml
LICENSE
README.md
composer.json
phpunit.xml

README.md

lumen-sns-middleware

Build Status Scrutinizer Code Quality Coverage Status

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 message
  • HandleSubscriptionConfirmationMiddleware - automatically confirms SubscriptionConfirmation messages
  • HandleUnsubscribeConfirmationMiddleware - automatically confirms UnsubscribeConfirmation 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