siewwp/laravel-service-host

laravel server-to-server service host with HMAC authentication

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

This package is not auto-updated.

Last update: 2024-04-14 03:17:49 UTC


README

Installation

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

Publish service host config

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

Publish service host migration

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

Run migration

php artisan migrate

run the command below on console to create host

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

Guide

Authenticating client request

Add clients user provider in your auth.php configuration file.

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

Finally, you may use this provider in your guards configuration:

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

Sending a webhook notification

To send notification, create a notification and specify WebhookChannel::class like below:

<?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 [
            // ...
        ];
    }
    
    // ...
}

TODO

TEST