digiaonline/lumen-sns-middleware

This package is abandoned and no longer maintained. No replacement package was suggested.

Collection of middleware and helpers for dealing with AWS SNS notifications

1.1.0 2020-09-03 13:13 UTC

This package is auto-updated.

Last update: 2023-03-05 11:55:29 UTC


README

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