承接 dida/eventbus 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

dida/eventbus

Composer 安装命令:

composer require dida/eventbus

包简介

A lightweight PHP Event Bus library.

README 文档

README

A lightweight PHP Event Bus library for Dida Framework.

API

public static $free_hook_mode = true;

public static $context        = null;
public static $global_context = null;

public static function hasEvent(string $event): bool;
public static function regEvent(string $event): void;
public static function unregEvent(string $event): void;

public static function addEvent(string $event): void;     // alias of regEvent.
public static function removeEvent(string $event): void;  // alias of unregEvent.

public static function hook(string $event, callable $callback, array $parameters = [], ?string $callback_id = null);
public static function unhook(string $event, ?string $callback_id = null): void;

public static function trigger(string $event, $context = false): void;

Code


use Dida\EventBus;

// Register an event.
EventBus::regEvent("YOUR.EVENT");

// Hook some callbacks.
...
EventBus::hook("YOUR.EVENT", your_callback_1, [param1, param2, ...]);
...
EventBus::hook("YOUR.EVENT", your_callback_2, [param1, param2, ...]);
...
EventBus::hook("YOUR.EVENT", your_callback_3, [param1, param2, ...]);

// Optional: Put some data to $context or $global_context if needed.

// Trigger an event and execute all hooked callbacks.
EventBus::trigger("YOUR.EVENT");

// or if you want to pass some context data for the callbacks of this event.
EventBus::trigger("YOUR.EVENT", $some_context_data);

// or if you want to pass some context data in another way.
EventBus::$context = some_context_data;
EventBus::$global_context = some_global_data;
EventBus::trigger("YOUR.EVENT");

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-06-22

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固