2017 © Pedro Peláez
 

symfony-bundle audit-bundle

PB Web Media Audit Bundle for Symfony

image

pbweb/audit-bundle

PB Web Media Audit Bundle for Symfony

  • Friday, April 14, 2017
  • by DemonTPx
  • Repository
  • 3 Watchers
  • 2 Stars
  • 3,023 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 8 % Grown

The README.md

PB Web Media Audit Bundle

Provides an easily extendible Symfony Bundle to create an audit log., (*1)

Installation

Install the audit-bundle using composer:, (*2)

composer require pbweb/audit-bundle

Usage

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

$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., (*4)

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 1. The class name of $event 1. Pbweb\AuditBundle\Event\LogAuditEvent, (*5)

That way you can hook into generic flow moments or only respond to specific events., (*6)

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

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., (*8)

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., (*9)

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., (*10)

If you use these appenders, you need to add symfony/security to your project., (*11)

Loggers

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

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

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., (*14)

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., (*15)

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., (*16)

Configuration

You can optionally configure the audit bundle in your app/config.yml file, (*17)

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

© PB Web Media, (*18)

The Versions

05/01 2017

1.1.1

1.1.1.0

PB Web Media Audit Bundle for Symfony

  Sources   Download

MIT

The Requires

 

The Development Requires

bundle symfony audit

22/12 2016
22/12 2016