定制 rasuvaeff/yii3-webhooks-db 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

rasuvaeff/yii3-webhooks-db

Composer 安装命令:

composer require rasuvaeff/yii3-webhooks-db

包简介

Database-backed delivery and nonce storage for rasuvaeff/yii3-webhooks

README 文档

README

Stable Version Total Downloads Build Static analysis Psalm Level License

Database-backed delivery and nonce storage for rasuvaeff/yii3-webhooks. It provides production storage for delivery attempts and atomic replay protection.

Using an AI coding assistant? llms.txt has a compact API reference you can use.

Requirements

  • PHP 8.3+
  • rasuvaeff/yii3-webhooks ^1.0
  • yiisoft/db ^2.0
  • yiisoft/db-migration ^2.0
  • psr/clock ^1.0

Installation

composer require rasuvaeff/yii3-webhooks-db

Usage

Run M260612000000CreateWebhookTables to create webhook_deliveries and webhook_nonces.

use Psr\Clock\ClockInterface;
use Rasuvaeff\Yii3Webhooks\WebhookDelivery;
use Rasuvaeff\Yii3WebhooksDb\DbNonceStorage;
use Rasuvaeff\Yii3WebhooksDb\DbWebhookDeliveryStorage;

$deliveries = new DbWebhookDeliveryStorage(db: $db);
$nonces = new DbNonceStorage(db: $db, clock: $clock);

$delivery = WebhookDelivery::create(event: $event, endpoint: $endpoint);
$deliveries->save(delivery: $delivery);
$accepted = $nonces->add(nonce: $signature->getValue());

With yiisoft/config, this package binds only WebhookDeliveryStorage and NonceStorage.

API reference

DbWebhookDeliveryStorage

Method Description
save(delivery) Inserts or updates a delivery row
findPending(limit) Returns pending deliveries ordered by creation time
markDelivered(delivery) Stores the delivery as delivered
markFailed(delivery) Stores the delivery as failed
getById(id) Loads a delivery by ID

DbNonceStorage

Method Description
has(nonce) Checks whether a nonce exists
add(nonce) Atomic insert; returns false on duplicate
deleteOlderThan(threshold) Deletes old nonces for retention cleanup

Security

  • DbNonceStorage::add() relies on the primary key and catches duplicate-key errors.
  • DbWebhookDeliveryStorage persists only WebhookDelivery data, never endpoint secrets.
  • Keep nonce rows at least as long as your webhook timestamp tolerance window.

Examples

See examples/ for a runnable SQLite example.

Development

make install
make build
make cs-fix
make test
make test-coverage
make mutation
make release-check

License

BSD-3-Clause. See LICENSE.md.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2026-06-19

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固