飞鸟 / laravel-service-host
使用HMAC身份验证的laravel服务器间服务主机
v1.1.1
2018-07-30 08:18 UTC
Requires
- siewwp/php-hmac-http: ^1.1.2
- symfony/psr-http-message-bridge: ~1.0
- zendframework/zend-diactoros: ^1.7
Requires (Dev)
- illuminate/auth: ~5.4
- illuminate/database: ~5.4
- illuminate/http: ~5.4
- illuminate/notifications: ~5.4
- illuminate/routing: ~5.4
- vlucas/phpdotenv: ~2.0
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 [ // ... ]; } // ... }
待办事项
测试