Webhook Notifications driver
616,784
164
11
Package Data
Maintainer Username: laravel-notification-channels
Maintainer Contact: m.pociot@gmail.com (Marcel Pociot)
Package Create Date: 2016-08-14
Package Last Update: 2024-03-19
Home Page: https://laravel-notification-channels.com
Language: PHP
License: MIT
Last Refreshed: 2024-04-29 15:04:47
Package Statistics
Total Downloads: 616,784
Monthly Downloads: 13,800
Daily Downloads: 488
Total Stars: 164
Total Watchers: 11
Total Forks: 59
Total Open Issues: 7

Webhook notifications channel for Laravel 5.3

Latest Version on Packagist Software License Build Status StyleCI SensioLabsInsight Quality Score Code Coverage Total Downloads

This package makes it easy to send webhooks using the Laravel 5.3 notification system.

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.
  • userAgent(''): Accepts a string value for the Webhook user agent.
  • header($name, $value): Sets additional headers to send with the POST Webhook.

Changelog

Please see CHANGELOG for more information what has changed recently.

Testing

$ composer test

Security

If you discover any security related issues, please email m.pociot@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.