All Projects → xiidea → EasyAuditBundle

xiidea / EasyAuditBundle

Licence: MIT License
A Symfony Bundle To Log Selective Events

Programming Languages

PHP
23972 projects - #3 most used programming language
Twig
543 projects

Projects that are alternatives of or similar to EasyAuditBundle

librarify-back
Librarify. Creando una API con Symfony 5 es un curso completo sobre Symfony 5 en el que cuento cómo desarrollar una API desde cero empleando FOS Rest Bundle.
Stars: ✭ 30 (-64.29%)
Mutual labels:  symfony4, symfony5
doctrine-json-odm
JSON Object-Document Mapping bundle for Symfony and Doctrine
Stars: ✭ 15 (-82.14%)
Mutual labels:  symfony-bundle, symfony4
skeleton
4xxi Symfony Skeleton is an extension for the official Symfony Skeleton with symfony flex used in 4xxi
Stars: ✭ 54 (-35.71%)
Mutual labels:  symfony3, symfony4
sonata-multiupload-bundle
No description or website provided.
Stars: ✭ 29 (-65.48%)
Mutual labels:  symfony-bundle, symfony4
swoole-server-bundle
No description or website provided.
Stars: ✭ 15 (-82.14%)
Mutual labels:  symfony3, symfony4
auditor
auditor, the missing audit log library
Stars: ✭ 105 (+25%)
Mutual labels:  audit-log, audit-trail
mailchimp-bundle
MailChimp integration with Symfony and MailChimp API V3
Stars: ✭ 40 (-52.38%)
Mutual labels:  symfony-bundle, symfony3
EasyAdminPlusBundle
EasyAdminPlusBundle is a Symfony 4 wrapper for the amazing EasyCorp/EasyAdminBundle
Stars: ✭ 39 (-53.57%)
Mutual labels:  symfony-bundle, symfony4
dadata-bundle
Бандл для работы с API ДаДата.
Stars: ✭ 14 (-83.33%)
Mutual labels:  symfony4, symfony5
docusign-bundle
Symfony bundle to create electronic signatures with DocuSign
Stars: ✭ 27 (-67.86%)
Mutual labels:  symfony-bundle
BeelabUserBundle
👥 Simple user management for Symfony.
Stars: ✭ 17 (-79.76%)
Mutual labels:  symfony-bundle
LolautruchePaylineBundle
Symfony integration for Payline payment system
Stars: ✭ 15 (-82.14%)
Mutual labels:  symfony-bundle
AutoFormBundle
Automate Symfony form building
Stars: ✭ 68 (-19.05%)
Mutual labels:  symfony-bundle
hcaptcha-bundle
A Symfony 4+ bundle to bring hCaptcha into your forms
Stars: ✭ 15 (-82.14%)
Mutual labels:  symfony-bundle
zenit
Zenit is a daemon collector for metrics and log parsers for any MySQL variant and ProxySQL
Stars: ✭ 24 (-71.43%)
Mutual labels:  audit-log
EzCoreExtraBundle
Extra features for eZ Platform (v1.x compatible with eZ Publish 5.4)
Stars: ✭ 29 (-65.48%)
Mutual labels:  symfony-bundle
eav-bundle
A Symfony bundle for basic EAV management
Stars: ✭ 19 (-77.38%)
Mutual labels:  symfony-bundle
Symfony4-REST-API
www.thinktocode.com/2018/03/26/symfony-4-rest-api-part-1-fosrestbundle/
Stars: ✭ 54 (-35.71%)
Mutual labels:  symfony4
domain-event-bundle
Library to create the domain layer of your DDD application
Stars: ✭ 14 (-83.33%)
Mutual labels:  symfony-bundle
acl-bundle
Integrates the ACL Security component into Symfony applications.
Stars: ✭ 91 (+8.33%)
Mutual labels:  symfony-bundle

Easy Audit

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

A Symfony 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 than 5.0 you need to use EasyAuditBundle 1.4.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": "^2.0"
    }
}

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/MongoDB 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
    #audit_log_class : MyProject\Bundle\MyBundle\Entity\AuditLog                  #Required
    #doctrine_event_resolver : xiidea.easy_audit.default_doctrine_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_objects :                                              #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_doctrine_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

  • Since v1.4.7 EntityEventResolver been refactored to a simplified version, if your code directly depends on older version of the implementation you are advised to copy the content of old implementation from here

  • Since v2.0 The FosUserBundle Events are removed from UserEventResolver and Event class using Symfony\Contracts\* namespace

Cookbook

Look the cookbook for another interesting things.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].