Coder Social home page Coder Social logo

armorsuitable / eventtracker Goto Github PK

View Code? Open in Web Editor NEW
6.0 2.0 1.0 21 KB

In Web applications, there is often generated data by business that needs to be throughout the Web system or API, and the event data can be used for collection, monitoring, distribution, and so on.

PHP 100.00%

eventtracker's Introduction

事件系统的由来

在现代 Web应用系统当中,经常存在某个业务所产生的数据需要**“贯穿”**整个Web 系统/API 使用, 多可用于数据的收集,监控,分发等等, 并与其它的系统的相关关联(例如构建一条调用链,来控制系统的其他功能)

事件系统的工作原理

与 MVC框架类似,存在一个入口点(这里指事件触发点), 然后交给不同的分发器来分发,分发器发送至不同的处理层,最后完成事件的接收处理和使用

About Features

  • 实现某个目录的自动加载,与 PSR-4 规则一致

    • event ( 事件系统的主体 )
      • Utility ( 事件系统辅助的类库)
      • ..
    • tracker ( 事件系统追溯线 )
    • config ( 事件系统的行为配置 )
    • logs ( 事件系统产生的日志数据 )
  • 实现事件的数据流接收

    • 事件可以由 EventData, EventCore 两个部分组成
    • 事件数据目前可由传递数组产生
    • 事件数据实现了 魔术方法 __toString 所以事件数据可以直接被输出
    • 事件直接由 EventDispatcher 接受后追踪/处理
  • 实现事件的分发和数据监控

    • 事件的分发规则目前有三种类型: 泛型事件(通用名称)、具体名称、具体动作
    • 每个分发的规则下面均会绑定一个追踪器 (EventTracker 目录下)
    • 一般情况下,任何的事件都归属于泛型事件 ,在配置文件中以 * 表示。因而泛型事件所绑定的追踪器, 可收到任何来源的事件数据(可用于监控,调用链追踪等)
    • 具体名称事件所绑定的追踪器,仅能接收到所绑定事件的数据, 其他事件数据无法捕获到

使用方法:

  • 该事件系统可以直接对接原生的 PHP应用程序

  • 在根目录下 autoloader.php 实现了该系统的接入规则 直接引入即可。

  • 如果使用了 composer 则会和现有的 spl_autoload_register 产生冲突, 需要修改载入规则,具体详情可直接修改代码

  • 该系统引入了配置文件 .env (需要重新复制一份 .env.example) 即可

  • 默认情况下系统会开启追踪日志,(可通过修改配置文件来关闭)

  • 该系统可以自定义配置条目 配置文件在 config/settings.php 当中

  • 在 index.php 当中给出了使用范例

eventtracker's People

Stargazers

Cloudflying avatar Semi avatar kwan avatar  avatar  avatar Oemme avatar

Watchers

James Cloos avatar Oemme avatar

Forkers

ondrocks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.