承接 surgery3/db-event-log 相关项目开发

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

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

surgery3/db-event-log

最新稳定版本:5.0.1

Composer 安装命令:

composer require surgery3/db-event-log

包简介

Log events to a flexible database table within the application

README 文档

README

Helpers and classes to store an event log in your database for auditing.

To add the entity to doctrine's entity manager in config/packages/doctrine.yaml:

doctrine:
    dbal:
        # ...
    orm:
        # ...
        mappings:
            App:
                # ...
            DbEventLog:
                is_bundle: false
                type: annotation
                dir: '%kernel.project_dir%/vendor/surgery3/db-event-log/src/Entity'
                prefix: 'Surgery3\DbEventLog\Entity'
                alias: DbEventLog

Event Subscriber Setup

To add the event subscriber in config/services.yml:

services:
    # ...

    Surgery3\DbEventLog\EventSubscriber\EventLogSubscriber:
        tags:
            - { name: doctrine.event_subscriber, connection: default }

The IDbEventLogUserInfo works similarly to the RequestUserInfoInterface from surgery3/request-log. You can implement them both with the same service.

<?php

class AppUserInfo extends TokenStorageUserInfo implements RequestUserInfoInterface, IDbEventLogUserInfo
{
    public function __construct(LoggerInterface $logger, TokenStorageInterface $tokenStorage)
    {
        parent::__construct($logger, $tokenStorage, ["app"]);
    }
}

Entities that you want to log must implement ILoggedEntity. For convenience, there is a LoggedEntity class that they can inherit from to reduce some duplication.

Then register these services in services.yaml:

Surgery3\DbEventLog\Service\IDbEventLogUserInfo: '@App\Service\AppUserInfo'
<?php

class FundingRound extends LoggedEntity
{
    /**
     * @ORM\Id()
     * @ORM\Column(type="integer", unique=true)
     */
    private $id;

    public function getId(): ?int
    {
        return $this->id;
    }

    public function getEvents()
    {
        return $this->events;
    }
}

Run tests with:

vendor/bin/phpunit --bootstrap vendor/autoload.php tests

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: proprietary
  • 更新时间: 2025-06-04