承接 branchonline/yii2-eventtracker 相关项目开发

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

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

branchonline/yii2-eventtracker

Composer 安装命令:

composer require branchonline/yii2-eventtracker

包简介

Extends Yii2 framework with some event and state tracking classes.

README 文档

README

Latest Stable Version Total Downloads Latest Unstable Version License

For now, this package requires you to use yii2 with a Postgres database!

The eventtracker package can be used when wanting to keep track of events (happening at a point in time) and state (persisting for some period) information without remodelling your database.

Keep track of events and state information via an application component.

The eventtracker allows extension of tracker functionality by hooking your own additional classes into the core functionality.

Installation

Add

"branchonline/yii2-eventtracker": "2.0"

to your composer.json

Usage

Adjust the provided migration and make sure to insert the event types and state keys that you want to keep track of. Run the migration.

Create a class that extends branchonline\eventtracker\EventTypes and specify the event types as class consts.

Create a class that extends branchonline\eventtracker\StateKeys and specify the state keys as class consts.

Add

'eventtracker' => [
    'class'        => 'branchonline\eventtracker\EventTracker',
    'types_config' => '', // Class extending EventTypes
    'keys_config'  => '', // Class extending StateKeys
]

To your application config.

If you want to add additional processing of events after they are handled, create a class that implements PostEventInterface and hook it into the configuration like so

'eventtracker' => [
    'class'              => 'branchonline\eventtracker\EventTracker',
    'types_config'       => '', // Class extending EventTypes
    'keys_config'        => '', // Class extending StateKeys
    'post_event_handler' => '' // Your handler class, implementing the PostEventInterface
]

Now You can log your events and state by using the application component and do optional post-processing!

Examples

Log an event or a state change
// Log that MY_EVENT happened for the current user with the optional data.
Yii::$app->eventtracker->logEvent(EventTypes::MY_EVENT, ['optional' => "data"]);

// Log that the state of MY_KEY changed to ['x' => 100].
Yii::$app->eventtracker->logState(StateKeys::MY_KEY, ['x' => 100]);
Retrieve events or state
// Get the events between 1 jan 2016 and 1 feb 2016 for user 1 and 2 of type MY_EVENT_1 or MY_EVENT_2.
Yii::$app->eventtracker->eventsBetween(
    TrackerTime::fromUnixTimestamp(1451606400),
    TrackerTime::fromUnixTimestamp(1454284800),
    [1, 2],
    [EventTypes::MY_EVENT_1, EventTypes::MY_EVENT_2]
);

// Get the state of MY_KEY_1 and MY_KEY_2 at 1 jan 2016.
Yii::$app->eventtracker->stateAt(
    TrackerTime::fromUnixTimestamp(1451606400),
    [StateKeys::MY_KEY_1, StateKeys::MY_KEY_2]
);

统计信息

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

GitHub 信息

  • Stars: 1
  • Watchers: 5
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2016-05-03

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固