klaari / lumen-sns-middleware

Collection of middleware and helpers for dealing with AWS SNS notifications

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

About

Collection of middleware and helpers for dealing with AWS SNS notifications

License:MIT License


Languages

Language:PHP 100.0%