Download the PHP package ankurk91/laravel-ses-webhooks without Composer
On this page you can find all versions of the php package ankurk91/laravel-ses-webhooks. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package laravel-ses-webhooks
AWS SES Webhooks Client for Laravel
Handle AWS SES webhooks in Laravel php framework.
Installation
You can install the package via composer:
The service provider will automatically register itself.
You must publish the config file with:
Next, you must publish the migration with:
After the migration has been published you can create the webhook_calls
table by running the migrations:
Next, for routing, add this route (guest) to your routes/web.php
Behind the scenes this will register a POST
route to a controller provided by this package. Next, you must add that
route to the except
array of your VerifyCsrfToken
middleware:
It is recommended to set up a queue worker to precess the incoming webhooks.
Prepare your AWS console for SES webhooks
- Assuming that you have SES service up and running in your app already
- Create a configuration set
- Choose SNS as event destination
- Choose
HTTP
as delivery method for that newly created SNS topic - Specify the webhook URL as
${APP_URL}/webhooks/ses
- This package should auto confirm the subscription
- You need to specify the configuration set name in your
config/services.php
Usage
There are 2 ways to handle incoming webhooks via this package.
1 - Handling webhook requests using jobs
If you want to do something when a specific event type comes in; you can define a job for that event. Here's an example of such job:
After having created your job you must register it at the jobs
array in the config/ses-webhooks.php
config file. The
key should be lowercase and spaces should be replaced by _
. The value should be a fully qualified classname.
2 - Handling webhook requests using events and listeners
Instead of queueing jobs to perform some work when a webhook request comes in, you can opt to listen to the events this
package will fire. Whenever a valid request hits your app, the package will fire a ses-webhooks::<name-of-the-event>
event.
The payload of the events will be the instance of WebhookCall that was created for the incoming request.
You can listen for such event by registering the listener in your EventServiceProvider
class.
Here's an example of such listener class:
Pruning old webhooks (opt-in but recommended)
Update your app/Console/Kernel.php
file like:
This will delete records older than 30
days, you can modify this duration by publishing this config file.
Changelog
Please see CHANGELOG for more information what has changed recently.
Testing
Security
If you discover any security issue, please email pro.ankurk1[at]gmail[dot]com
instead of using the issue tracker.
Useful Links
- Receiving Amazon SES notifications using Amazon SNS
- AWS SES event publishing
- AWS SNS JSON format
- AWS SES Event format
Acknowledgment
This package is highly inspired by:
- https://github.com/spatie/laravel-mailcoach-ses-feedback
- https://github.com/spatie/laravel-stripe-webhooks
License
This package is licensed under MIT License.
All versions of laravel-ses-webhooks with dependencies
ext-openssl Version *
aws/aws-php-sns-message-validator Version ^1.8
guzzlehttp/guzzle Version ^7.5
illuminate/http Version ^10.0 || ^11.0
illuminate/support Version ^10.0 || ^11.0
spatie/laravel-webhook-client Version ^3.1.7