PHP Classes
elePHPant
Icontem

Easy PHP Audit Log Bundle: Log specific events according to configuration

Recommend this page to a friend!
  Info   View files Documentation   View files View files (118)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2018-07-04 (1 year ago) RSS 2.0 feedNot yet rated by the usersTotal: 97 All time: 9,256 This week: 285Up
Version License PHP version Categories
easyauditbundle 1.4Custom (specified...5.6PHP 5, Libraries, Logging
Description Author

This package can log specific events according to configuration.

It provides different components that can play different roles in the process of logging events that happen in an application.

There is a resolver component that takes an event and determines how to map its context to information to be logged.

There is also a channel component that can be used to select the level of severity of the events to be logged.

Innovation Award
PHP Programming Innovation award nominee
September 2018
Number 4
Every application should create logs of relevant actions that happen during its execution so it is possible later to be able to determine the possible reasons that caused something that went wrong.

This provides an alternative solution to the process of logging specific types of logging.

It takes the information about events to be logged in the form of object that provides all the action details, a resolver component that take the event information and passes it to a specific channel component that filters the interesting actions to generate the actual logs.

Manuel Lemos
  Performance   Level  
Name: Roni is available for providing paid consulting. Contact Roni .
Classes: 7 packages by
Country: Bangladesh Bangladesh
Age: ???
All time rank: 363748 in Bangladesh Bangladesh
Week rank: 115 Up3 in Bangladesh Bangladesh Up
Innovation award
Innovation award
Nominee: 2x

 

Details

Easy Audit

Build Status HHVM Status Coverage Status Scrutinizer Code Quality Latest Stable Version Total Downloads SensioLabsInsight knpbundles.com

A Symfony2 Bundle To Log Selective Events. It is easy to configure and easy to customize for your need.

Note: If you are using Symfony version older then 2.4 you need to use EasyAuditBundle 1.2.x Note: If you are using Symfony version older then 2.6 you need to use EasyAuditBundle 1.3.x

Install

  1. Add EasyAuditBundle in your composer.json
  2. Enable the Bundle
  3. Create audit_log entity class
  4. Configure config.yml
  5. Update Database Schema

1. Add EasyAuditBundle in your composer.json

Add EasyAuditBundle in your composer.json:

{
    "require": {
        "xiidea/easy-audit": "^1.4"
    }
}

Now tell composer to download the bundle by running the command:

$ php composer.phar update xiidea/easy-audit

Composer will install the bundle to your project's vendor/xiidea directory.

2. Enable the Bundle

<?php
// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new Xiidea\EasyAuditBundle\XiideaEasyAuditBundle(),
    );
}

3. Create audit_log entity class

The XiideaEasyAuditBundle supports Doctrine ORM by default. However, you must provide a concrete AuditLog class. Follow the instructions to set up the class:

4. Configure config.yml

You can find sample config data in Resources/config/config-sample.yml file

# app/config/config.yml
xiidea_easy_audit:
    #resolver: xiidea.easy_audit.default_event_resolver                           #Optional
    #entity_class : MyProject\Bundle\MyBundle\Entity\AuditLog                     #Required
    #entity_event_resolver : xiidea.easy_audit.default_entity_event_resolver      #Optional
    #default_logger : true                                                        #Optional
    
    #user property to use as actor of an event
    #valid value will be any valid property of your user class
    user_property : ~ # or username                            #Optional

    #List of doctrine entity:event you wish to track or set to false to disable logs for doctrine events
    # valid events are = [created, updated, deleted]
    #doctrine_entities :                                              #Optional
    #     MyProject\Bundle\MyBundle\Entity\MyEntity : [created, updated, deleted]
    #     MyProject\Bundle\MyBundle\Entity\MyEntity2 : []

    #List all events you want to track  (Optional from v1.2.1 you can now use subscriber to define it)
    events :                                                   #Optional
        - security.interactive_login

    #List all custom resolver for event
    #custom_resolvers :
    #       security.interactive_login : user.event_resolver
    #       security.authentication.failure : user.event_resolver

    #logger_channel:
    #    xiidea.easy_audit.logger.service: ["info", "debug"]
    #    file.logger: ["!info", "!debug"]

    #Custom Event Resolver Service
services:
    #user.event_resolver:
    #     class: Xiidea\EasyAuditBundle\Resolver\UserEventResolver
    #     calls:
    #        - [ setContainer,[ @service_container ] ]

5. Update Database Schema

As all setup done, now you need to update your database schema. To do so,run the following command from your project directory

$ php app/console doctrine:schema:update --force

Core Concepts

Logger:

Logger is the core service which are responsible for persist the event info. You can define as many logger as you like. EasyAudit Bundled with a logger service xiidea.easy_audit.logger.service which is the default logger service. You can easily disable the service by setting default_logger: false in configuration.

Resolver:

Resolver is like translator for an event. It used to translate an event to AuditLog entity. EasyAudit bundled with two(2) resolver services xiidea.easy_audit.default_event_resolver, xiidea.easy_audit.default_entity_event_resolver. And a custom EventResolver class UserEventResolver to illustrate how the transformation works. You can define as many resolver service as you want and use them to handle different event. Here is the place you can set the severity level for a event. Default level is Psr\Log\LogLevel::INFO. Custom severity levels are not available. EasyAudit supports the logging levels described by PSR-3. These values are present for basic filtering purposes. You can use this value as channel to register different logger to handle different event. If you add any other field to your AuditLog object, this is the place to add those extra information (tags, metadata, etc..)

Channel

It is now possible to register logger for specific channel. channel is refers to log level. you can configure EasyAudit logger services to handle only specific level of event.

Warning - BC Breaking Changes

  • Since v1.2.2 pre_persist_listener option has been removed. You can use this cookbook to achieve the same functionality
  • Since v1.2.2 EventResolverInterface been split into EmbeddedEventResolverInterface and EventResolverInterface
  • Since v1.3.x The new Event object has been adapted. And the signature of EmbeddedEventResolverInterface and EventResolverInterface also changed. Now it expects extra $eventName parameter

Cookbook

Look the cookbook for another interesting things.

  Files folder image Files  
File Role Description
Files folder imageAnnotation (1 file)
Files folder imageCommon (1 file)
Files folder imageController (1 file)
Files folder imageDependencyInjection (2 files, 1 directory)
Files folder imageEntity (1 file)
Files folder imageEvents (2 files)
Files folder imageException (3 files)
Files folder imageListener (1 file)
Files folder imageLogger (4 files)
Files folder imageResolver (6 files, 1 directory)
Files folder imageResources (3 directories)
Files folder imageSubscriber (3 files)
Files folder imageTests (3 files, 10 directories)
Files folder imageTraits (2 files)
Accessible without login Plain text file .coveralls.yml Data Auxiliary data
Accessible without login Plain text file .scrutinizer.yml Data Auxiliary data
Accessible without login Plain text file .travis.yml Data Auxiliary data
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file phpunit.xml.dist Data Auxiliary data
Accessible without login Plain text file README.md Doc. Documentation
Plain text file XiideaEasyAuditBundle.php Class Class source

  Files folder image Files  /  Annotation  
File Role Description
  Plain text file ORMSubscribedEvents.php Class Class source

  Files folder image Files  /  Common  
File Role Description
  Plain text file UserAwareComponent.php Class Class source

  Files folder image Files  /  Controller  
File Role Description
  Plain text file DefaultController.php Class Class source

  Files folder image Files  /  DependencyInjection  
File Role Description
Files folder imageCompiler (3 files)
  Plain text file Configuration.php Class Class source
  Plain text file XiideaEasyAuditExtension.php Class Class source

  Files folder image Files  /  DependencyInjection  /  Compiler  
File Role Description
  Plain text file LoggerFactoryPass.php Class Class source
  Plain text file MonologLoggerPass.php Class Class source
  Plain text file SubscriberPass.php Class Class source

  Files folder image Files  /  Entity  
File Role Description
  Plain text file BaseAuditLog.php Class Class source

  Files folder image Files  /  Events  
File Role Description
  Plain text file DoctrineEntityEvent.php Class Class source
  Plain text file DoctrineEvents.php Class Class source

  Files folder image Files  /  Exception  
File Role Description
  Plain text file InvalidServiceException.php Class Class source
  Plain text file UnrecognizedEntityException.php Class Class source
  Plain text file UnrecognizedEventInfoException.php Class Class source

  Files folder image Files  /  Listener  
File Role Description
  Plain text file LogEventsListener.php Class Class source

  Files folder image Files  /  Logger  
File Role Description
  Plain text file Logger.php Class Class source
  Plain text file LoggerFactory.php Class Class source
  Plain text file LoggerInterface.php Class Class source
  Plain text file MonologLogger.php Class Class source

  Files folder image Files  /  Resolver  
File Role Description
Files folder imageUserEventCommand (6 files)
  Plain text file DefaultEventResolver.php Class Class source
  Plain text file EmbeddedEventResolverInterface.php Class Class source
  Plain text file EntityEventResolver.php Class Class source
  Plain text file EventResolverFactory.php Class Class source
  Plain text file EventResolverInterface.php Class Class source
  Plain text file UserEventResolver.php Class Class source

  Files folder image Files  /  Resolver  /  UserEventCommand  
File Role Description
  Plain text file AuthenticationFailedCommand.php Class Class source
  Plain text file ImplicitLoginCommand.php Class Class source
  Plain text file InteractiveLoginCommand.php Class Class source
  Plain text file PasswordChangedCommand.php Class Class source
  Plain text file ResolverCommand.php Class Class source
  Plain text file UserLoginCommand.php Class Class source

  Files folder image Files  /  Resources  
File Role Description
Files folder imageconfig (4 files, 1 directory)
Files folder imagedoc (9 files)
Files folder imageviews (1 directory)

  Files folder image Files  /  Resources  /  config  
File Role Description
Files folder imagedefault (3 files)
  Accessible without login Plain text file config-sample.yml Data Auxiliary data
  Accessible without login Plain text file doctrine_services.yml Data Auxiliary data
  Accessible without login Plain text file routing.yml Data Auxiliary data
  Accessible without login Plain text file services.yml Data Auxiliary data

  Files folder image Files  /  Resources  /  config  /  default  
File Role Description
  Accessible without login Plain text file entity-event-resolver.yml Data Auxiliary data
  Accessible without login Plain text file event-resolver.yml Data Auxiliary data
  Accessible without login Plain text file logger.yml Data Auxiliary data

  Files folder image Files  /  Resources  /  doc  
File Role Description
  Plain text file audit-log-entity-orm.md Class Class source
  Plain text file custom-logger.md Class Class source
  Plain text file custom-resolver.md Class Class source
  Plain text file doctrine-entity-events.md Class Class source
  Plain text file embed-resolver.md Class Class source
  Accessible without login Plain text file logger-channel.md Data Auxiliary data
  Accessible without login Plain text file override-resolver.md Data Auxiliary data
  Plain text file pre-persist-listener.md Class Class source
  Plain text file subscriber.md Class Class source

  Files folder image Files  /  Resources  /  views  
File Role Description
Files folder imageDefault (1 file)

  Files folder image Files  /  Resources  /  views  /  Default  
File Role Description
  Accessible without login Plain text file index.html.twig Data Auxiliary data

  Files folder image Files  /  Subscriber  
File Role Description
  Plain text file DoctrineDeleteEventLogger.php Class Class source
  Plain text file DoctrineSubscriber.php Class Class source
  Plain text file EasyAuditEventSubscriberInterface.php Class Class source

  Files folder image Files  /  Tests  
File Role Description
Files folder imageAnnotation (1 file)
Files folder imageCommon (1 file)
Files folder imageDependencyInjection (1 file, 1 directory)
Files folder imageEntity (1 file)
Files folder imageFixtures (3 directories)
Files folder imageFunctional (5 files, 3 directories)
Files folder imageListener (1 file)
Files folder imageLogger (3 files)
Files folder imageResolver (3 files)
Files folder imageSubscriber (2 files)
  Accessible without login Plain text file bootstrap.php Aux. Auxiliary script
  Plain text file XiideaEasyAuditBundleTest.php Class Class source
  Plain text file XiideaTestListener.php Class Class source

  Files folder image Files  /  Tests  /  Annotation  
File Role Description
  Plain text file ORMSubscribedEventsTest.php Class Class source

  Files folder image Files  /  Tests  /  Common  
File Role Description
  Plain text file UserAwareComponentTest.php Class Class source

  Files folder image Files  /  Tests  /  DependencyInjection  
File Role Description
Files folder imageCompiler (3 files)
  Plain text file XiideaEasyAuditExtensionTest.php Class Class source

  Files folder image Files  /  Tests  /  DependencyInjection  /  Compiler  
File Role Description
  Plain text file LoggerFactoryPassTest.php Class Class source
  Plain text file MonologLoggerPassTest.php Class Class source
  Plain text file SubscriberPassTest.php Class Class source

  Files folder image Files  /  Tests  /  Entity  
File Role Description
  Plain text file BaseAuditLogTest.php Class Class source

  Files folder image Files  /  Tests  /  Fixtures  
File Role Description
Files folder imageCommon (11 files)
Files folder imageEvent (6 files)
Files folder imageORM (5 files)

  Files folder image Files  /  Tests  /  Fixtures  /  Common  
File Role Description
  Plain text file AuditObjectResolver.php Class Class source
  Plain text file CustomEventResolver.php Class Class source
  Plain text file DummyLifecycleEventArgs.php Class Class source
  Plain text file DummyToken.php Class Class source
  Plain text file DummyUserAwareComponent.php Class Class source
  Plain text file EasySubscriberOne.php Class Class source
  Plain text file EasySubscriberTwo.php Class Class source
  Plain text file InvalidEventInfoResolver.php Class Class source
  Plain text file InvalidEventResolver.php Class Class source
  Plain text file InvalidLogger.php Class Class source
  Plain text file NullResolver.php Class Class source

  Files folder image Files  /  Tests  /  Fixtures  /  Event  
File Role Description
  Plain text file Basic.php Class Class source
  Plain text file DummyAuthenticationFailureEvent.php Class Class source
  Plain text file DummyFilterUserResponseEvent.php Class Class source
  Plain text file DummyUserEvent.php Class Class source
  Plain text file EntityEvent.php Class Class source
  Plain text file WithEmbeddedResolver.php Class Class source

  Files folder image Files  /  Tests  /  Fixtures  /  ORM  
File Role Description
  Plain text file AuditLog.php Class Class source
  Plain text file DummyEntity.php Class Class source
  Plain text file EntityWithoutGetMethod.php Class Class source
  Plain text file Movie.php Class Class source
  Plain text file UserEntity.php Class Class source

  Files folder image Files  /  Tests  /  Functional  
File Role Description
Files folder imageBundle (1 directory)
Files folder imageconfig (2 files, 1 directory)
Files folder imageResources (1 directory)
  Plain text file BaseTestCase.php Class Class source
  Plain text file CommonTest.php Class Class source
  Plain text file ImpersonatingUserTest.php Class Class source
  Plain text file ImpersonatingUserTestKernel.php Class Class source
  Plain text file TestKernel.php Class Class source

  Files folder image Files  /  Tests  /  Functional  /  Bundle  
File Role Description
Files folder imageTestBundle (1 file, 3 directories)

  Files folder image Files  /  Tests  /  Functional  /  Bundle  /  TestBundle  
File Role Description
Files folder imageController (1 file)
Files folder imageEntity (1 file)
Files folder imageLogger (1 file)
  Plain text file XiideaTestBundle.php Class Class source

  Files folder image Files  /  Tests  /  Functional  /  Bundle  /  TestBundle  /  Controller  
File Role Description
  Plain text file DefaultController.php Class Class source

  Files folder image Files  /  Tests  /  Functional  /  Bundle  /  TestBundle  /  Entity  
File Role Description
  Plain text file AuditLog.php Class Class source

  Files folder image Files  /  Tests  /  Functional  /  Bundle  /  TestBundle  /  Logger  
File Role Description
  Plain text file FileLogger.php Class Class source

  Files folder image Files  /  Tests  /  Functional  /  config  
File Role Description
Files folder imagecommon (4 files)
  Accessible without login Plain text file config.yml Data Auxiliary data
  Accessible without login Plain text file switchuser.yml Data Auxiliary data

  Files folder image Files  /  Tests  /  Functional  /  config  /  common  
File Role Description
  Accessible without login Plain text file framework.yml Data Auxiliary data
  Accessible without login Plain text file logiin_routing.yml Data Auxiliary data
  Accessible without login Plain text file routing.yml Data Auxiliary data
  Accessible without login Plain text file security.yml Data Auxiliary data

  Files folder image Files  /  Tests  /  Functional  /  Resources  
File Role Description
Files folder imageviews (1 file)

  Files folder image Files  /  Tests  /  Functional  /  Resources  /  views  
File Role Description
  Accessible without login Plain text file base.html.twig Data Auxiliary data

  Files folder image Files  /  Tests  /  Listener  
File Role Description
  Plain text file LogEventsListenerTest.php Class Class source

  Files folder image Files  /  Tests  /  Logger  
File Role Description
  Plain text file LoggerFactoryTest.php Class Class source
  Plain text file LoggerTest.php Class Class source
  Plain text file MonologLoggerTest.php Class Class source

  Files folder image Files  /  Tests  /  Resolver  
File Role Description
  Plain text file EntityEventResolverTest.php Class Class source
  Plain text file EventResolverFactoryTest.php Class Class source
  Plain text file UserEventResolverTest.php Class Class source

  Files folder image Files  /  Tests  /  Subscriber  
File Role Description
  Plain text file DoctrineDeleteEventLoggerTest.php Class Class source
  Plain text file DoctrineSubscriberTest.php Class Class source

  Files folder image Files  /  Traits  
File Role Description
  Plain text file EntityHydrationMethod.php Class Class source
  Plain text file ServiceContainerGetterMethods.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:97
This week:0
All time:9,256
This week:285Up