Download the PHP package nipwaayoni/laravel-aws-sns without Composer

On this page you can find all versions of the php package nipwaayoni/laravel-aws-sns. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-aws-sns

Laravel SNS Handler

This package provides an easy way of adding AWS SNS message handling to your Laravel application as a REST endpoint. The package can automatically confirm subscription requests and dispatches events when a message is received.

How to create an SNS topic

The creation of the AWS SNS topic is outside the scope of this package. Please refer to the AWS documentation for creating a topic.

How to add SNS Handler to your Application

Use composer to require the package:

Note that this package only supports versions of Laravel under active support. At this time that includes Laravel 6 (LTS) and Laravel 8 or higher.

Handling events

Please review the Laravel documentation on Events.. You will need to write a listener to handle the events associated with the ARNs you register. Your listener class must handle the appropriate event, SnsMessageReceived by default. (See the section on dispatching events for more options.) Your listener must then be registered in the EventServiceProvider as mentioned in the Events documentation:

In your listener, the handle method will receive an SnsMessageReceived object which can be used to access the SnsMessage.

The message content will always be a string. You are responsible for any deserialization or other steps required to interpret the message content.

Dispatching specific events for specific ARNs

This package supports dispatching your own specific events (both subscription and notification events) for messages from specific topics. The mapping of message ARNs to Event classes is done in the config/sns-handler.php configuration file of your application (ensure this is published if it does not exist in your project).

The map keys must be a resolvable class which provides an event dispatch method (typically done by using the Illuminate\Foundation\Events\Dispatchable trait). The value of each map key must be an array of one or more AWS SNS topic ARNs. Each ARN should appear only once in the map.

Note that the map is parsed in order, so the first match found in the list will be the class dispatched.

Note that a default event class is not required, but if a matching event cannot be found in the map, a 404 will be returned if a message is sent using that ARN.

Write a feature test to test the expected SNS feature

The SnsHttpTestHelperTrait facilitates testing. Use the trait in your test to make testing your application easier.

Sample test:

Message signature validation

SNS messages are signed and should be validated before being processed. This package will perform that validation on your behalf and reject messages which cannot be validated. Because message signature validation requires cryptographically correct attributes in the message, submitting test messages without an actual SNS topic is a problem. In those cases, you can disable this validation by adding the following to your .env:

Important! Message validation should never be disabled in your production application. Only use this option to disable validation for testing purposes.

How do I send SNS messages to my app?

This package adds a route (/api/sns/message) to handle SNS requests. The SNS message route responds to POST requests and expects content consistent with an SNS message from AWS. Note that because this is an api route, any API middleware you have applied in your application will affect this route.

You can find examples of both subscription confirmation and notification message HTTP requests here.

The message content of an SNS message must be provided as a string value. If your payload is something other than a simple string (e.g. an array or some other sort of object), you will need to serialize your data before sending it using something like json_encode().

POSTing directly to your app

Amazon has an example of a POST request available here. You can add your serialized message in the message field. Note that manually POSTed messages cannot be validated (See above to disable message validation). We recommend only attempting this during testing, never in your production environment.

How to subscribe your endpoint in AWS

You will use the full URL to the message handling route when subscribing to your topic. The route will be {Your application's base URL}/api/sns/message. Follow these instructions to subscribe your endpoint using HTTPS.

This package is configured to automatically respond to all SNS subscription confirmation requests sent to its endpoint. This can be disabled by adding the following to your .env file:

Note: You will only be able to subscribe your endpoint if it can be reached from the AWS SNS service (i.e. the public internet).

Development

This package is expected to work with supported versions of Laravel, including LTS releases. During development, you should be sure to run tests and validate expected behaviors under different releases. Since we use the orchestra/testbench package, you can easily switch between installed Laravel framework releases using composer:

New releases of Laravel should be added to the GitHub workflow matrix in .github/workflows/run-tests.yml.


All versions of laravel-aws-sns with dependencies

PHP Build Version
Package Version
Requires php Version >=7.3
ext-json Version *
aws/aws-php-sns-message-validator Version ^1.6
php-http/discovery Version ^1.14
psr/http-factory Version ^1.0
psr/http-client Version ^1.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package nipwaayoni/laravel-aws-sns contains the following files

Loading the files please wait ....