定制 psp-biz/event-service 二次开发

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

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

psp-biz/event-service

最新稳定版本:v1.0.3

Composer 安装命令:

composer require psp-biz/event-service

包简介

A framework-agnostic event service library.

README 文档

README

This Event Service Library provides a simple interface for PHP applications to dispatch events to a specified endpoint. It is designed to be framework-agnostic and can be used with any PHP project that uses Composer for dependency management.

Features

  • Framework-agnostic implementation.
  • Supports PSR-4 autoloading.
  • Implements PSR-7 HTTP message interfaces and PSR-18 HTTP Client for communication.
  • Utilizes Monolog for logging event dispatching processes.
  • Configurable to handle different endpoints and authentication methods.
  • Provides an easy-to-use API for dispatching events.

Installation

Use Composer to install the Event Producer Library into your project:

composer require psp-biz/event-service

Usage

To use the Event Producer, you need to require the Composer autoload file and instantiate the EventProducer class. Then, dispatch events using the dispatchEvent method:

require_once __DIR__ . '/vendor/autoload.php';

use YourVendor\EventProducer\EventProducer;

// Initialize the Event Producer
$eventProducer = new EventProducer();

// Dispatch an event
$eventProducer->dispatchEvent('event.name', [
    // Event data array
]);

The dispatchEvent method takes two parameters:

  1. eventName (string): The name of the event you want to dispatch.
  2. eventData (array): An associative array containing the data for the event.

Configuration

By default, the library is configured to log to logs/events.log and send events to a predefined endpoint. To customize these settings, you can modify the constructor of the EventService class or expose configuration methods as needed.

Logging

The library uses Monolog for logging. Logs are written to logs/events.log. You can change the log settings by editing the EventService class constructor.

Dependencies

The library depends on the following packages:

  • guzzlehttp/guzzle: For sending HTTP requests.
  • http-interop/http-factory-guzzle: PSR-17 HTTP Factory implementation for Guzzle.
  • monolog/monolog: For logging events and errors.

Contributing

No need, thanks though.

License

The Event Service Library is open-sourced software licensed under the MIT license.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-11-14