飞鸟/laravel-service-host

使用HMAC身份验证的laravel服务器间服务主机

v1.1.1 2018-07-30 08:18 UTC

This package is not auto-updated.

Last update: 2024-09-29 05:42:02 UTC


README

安装

composer require siewwp/laravel-service-host:^1.0.0

发布服务主机配置

php artisan vendor:publish --provider="Siewwp\LaravelServiceHost\ServiceHostServiceProvider" --tag="config"

发布服务主机迁移

php artisan vendor:publish --provider="Siewwp\LaravelServiceHost\ServiceHostServiceProvider" --tag="migrations"

运行迁移

php artisan migrate

在控制台运行以下命令以创建主机

php artisan service-host:client {name} {webhook_url}

指南

验证客户端请求

将客户端用户提供者在您的 auth.php 配置文件中添加。

'providers' => [
    'clients' => [
        'driver' => 'eloquent',
        'model' => Siewwp\LaravelServiceHost\Client::class,
    ],
],

最后,您可以在 guards 配置中使用此提供者

'guards' => [
    'client' => [
        'driver' => 'service-host',
        'provider' => 'clients',
    ],
],

发送webhook通知

要发送通知,创建一个通知并指定 WebhookChannel::class,如下所示

<?php

namespace App\Notifications;

use Illuminate\Notifications\Notification;
use Siewwp\LaravelServiceHost\Channels\WebhookChannel;

class InvoicePaid extends Notification
{
    public function via($notifiable)
    {
        return [WebhookChannel::class];
    }
    
    public function toWebhook($notifiable)
    {
        return [
            // ...
        ];
    }
    
    // ...
}

待办事项

测试