laravel-notification-channels / webhook
Webhook Notifications driver
Installs: 745 994
Dependents: 7
Suggesters: 2
Security: 0
Stars: 170
Watchers: 10
Forks: 61
Open Issues: 8
Requires
- php: ^7.2.5 || ^8.0
- guzzlehttp/guzzle: ^6.2 || ^7.0
- illuminate/notifications: ^6.0 || ^7.0 || ^8.0 || ^9.0 || ^10.0 || ^11.0
- illuminate/support: ^6.0 || ^7.0 || ^8.0 || ^9.0 || ^10.0 || ^11.0
Requires (Dev)
- mockery/mockery: ^1.3
- orchestra/testbench: ^4.0 || ^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.0
- phpunit/phpunit: ^9.0 || ^10.5
README
This package makes it easy to send webhooks using the Laravel notification system.
Compatibility
Contents
Installation
You can install the package via composer:
composer require laravel-notification-channels/webhook
Usage
Now you can use the channel in your via()
method inside the notification:
use NotificationChannels\Webhook\WebhookChannel; use NotificationChannels\Webhook\WebhookMessage; use Illuminate\Notifications\Notification; class ProjectCreated extends Notification { public function via($notifiable) { return [WebhookChannel::class]; } public function toWebhook($notifiable) { return WebhookMessage::create() ->data([ 'payload' => [ 'webhook' => 'data' ] ]) ->userAgent("Custom-User-Agent") ->header('X-Custom', 'Custom-Header'); } }
In order to let your Notification know which URL should receive the Webhook data, add the routeNotificationForWebhook
method to your Notifiable model.
This method needs to return the URL where the notification Webhook will receive a POST request.
public function routeNotificationForWebhook() { return 'http://requestb.in/1234x'; }
Available methods
data('')
: Accepts a JSON-encodable value for the Webhook body.query('')
: Accepts an associative array of query string values to add to the request.userAgent('')
: Accepts a string value for the Webhook user agent.header($name, $value)
: Sets additional headers to send with the POST Webhook.verify()
: Enable the SSL certificate verification or provide the path to a CA bundle
Changelog
Please see CHANGELOG for more information what has changed recently.
Testing
$ composer test
Security
If you discover any security related issues, please email atymicq@gmail.com instead of using the issue tracker.
Contributing
Please see CONTRIBUTING for details.
Credits
License
The MIT License (MIT). Please see License File for more information.