定制 pbweb/audit-bundle 二次开发

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

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

pbweb/audit-bundle

Composer 安装命令:

composer require pbweb/audit-bundle

包简介

PB Web Media Audit Bundle for Symfony

README 文档

README

Provides an easily extendible Symfony Bundle to create an audit log.

Installation

Install the audit-bundle using composer:

composer require pbweb/audit-bundle

Usage

To insert an entry in the audit logger, create an AuditEvent and give it to the AuditLog

$event = new \Pbweb\AuditBundle\Event\AuditEvent('test');
$log = $container->get('pbweb_audit.audit_log');
$log->log($event);

You can also create your own events (which we recommend), as long as they implement the AuditEventInterface.

Flow

Events enter the audit logger which will then trigger the following events (in order) with the provided AuditEventInterface event as an argument:

  1. Pbweb\AuditBundle\Event\AppendAuditEvent
  2. The class name of $event
  3. Pbweb\AuditBundle\Event\LogAuditEvent

That way you can hook into generic flow moments or only respond to specific events.

The Audit Bundle uses the Symfony event system so all the normal shenanigans (like listener priorities, stopping propagation, etc) work when handling these events.

Event appenders

Events aren't usually complete by themselves, you probably want to append some data related to the event like the user that triggered it or the ip of the client.

To do this listen to the Pbweb\AuditBundle\Event\AppendAuditEvent event (either through a listener or subscriber). It will receive all AuditEventInterface events that go into the audit log.

Default event appenders

The Audit Bundle comes packaged with a few event appenders that will be loaded by default, see the configuration section below on how to disable that.

If you use these appenders, you need to add symfony/security to your project.

Loggers

Eventually the audit log entries need to go somewhere, either the database, a PSR logger or whatever you can think of.

The Audit Bundle comes packaged with a PSR logger and Doctrine logger (see below).

You can also implement your own logger by listening to the Pbweb\AuditBundle\Event\LogAuditEvent event. It will receive all AuditEventInterface events that go into the audit log.

PSR logger

By default the Audit Bundle loads the PsrLogger, which will use the @logger service to log events to your default log. Look at the configuration section below on how to disable this behaviour.

Doctrine logger

For small(ish) audit logs you could use the database as a data store. The Audit Bundle comes with an AbstractDoctrineLogger. The only thing you need to do is create a service that implements the convertToEntity method and give it the tag kernel.event_subscriber.

Configuration

You can optionally configure the audit bundle in your app/config.yml file

pbweb_audit:
    load_default_event_loggers: true    # loads the loggers defined in Pbweb/AuditBundle/Resources/config/default/loggers.yml
    load_default_event_appenders: true  # loads the event appenders in Pbweb/AuditBundle/Resources/config/default/appenders.yml

Copyright

© PB Web Media

pbweb/audit-bundle 适用场景与选型建议

pbweb/audit-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 6.73k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2016 年 12 月 22 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「symfony」 「bundle」 「Audit」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 pbweb/audit-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 pbweb/audit-bundle 我们能提供哪些服务?
定制开发 / 二次开发

基于 pbweb/audit-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-12-22