juststeveking/webhooks 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

juststeveking/webhooks

最新稳定版本:0.0.2

Composer 安装命令:

composer require juststeveking/webhooks

包简介

The simplest way to start sending webhooks in PHP.

README 文档

README

Latest Version Software License Run Tests PHP Version Total Downloads

The simplest way to start sending webhooks in PHP.

Installation

You can install this library using composer:

composer require juststeveking/webhooks

The next step is to install a OSR compliant package to do the request itself, you will need:

  • PSR 7 Request Library
  • PSR17 Request and Stream Factories
  • PSR18 Http Client

This package will auto-discover these packages you have installed for you, so you not need to wire anything up.

Usage

This package is super simple to get started with, all you need to do is build one class and you can start sending webhooks.

use JustSteveKing\Webhooks\Webhook;

class YourWebhook extends Webhook
{
    public function headers(): array
    {
        $signature = hash_hmac(
            algo: 'sha256',
            data: \Safe\json_encode(
                value: $this->buildPayload(),
                flags: JSON_THROW_ON_ERROR,
            ),
            key: 'Your signing key goes here',
        );

        return [
            'Content-Type' => 'application/json',
            'Signature' => $signature,
        ];
    }

    public function buildPayload(): array
    {
        return [
            'foo' => 'bar',
        ];
    }

    public function url(): string
    {
        return 'Your URL goes here.';
    }

    public function method(): Method
    {
        return Method::POST;
    }

    public function plugins(): array
    {
        return [];
    }
}

The HTTP Client used for sending your HTTP requests supports plugins, you can see how these work here.

Tests

There is a composer script available to run the tests:

composer test

However, if you are unable to run this please use the following command:

./vendor/bin/pest

Security

If you discover any security related issues, please email juststevemcd@gmail.com instead of using the issue tracker.

统计信息

  • 总下载量: 9
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 4
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 4
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-03-19