YII2 PHP Audit Log: Create logs to track changes in database records

Recommend this page to a friend!
  Info   Documentation   View files (13)   Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 83 All time: 9,540 This week: 373
Version License PHP version Categories
yii2-audit-log 1.0Free for non-comm...5.6PHP 5, Databases, Logging, Design Pat...
Description Author

This package can be used to create logs to track changes in database records.

It provides a class that can be used to implement a behavior to create audit logs for changes performed in model that stores data object values in a database.

The class can record in a log the type of change that was performed, the current user ID and IP address, as well the names and values of the records that were changed.

Innovation Award
PHP Programming Innovation award nominee
July 2019
Number 10
Audit logs are useful to identify the circumstances that caused changes in the data of applications, like for instance the data that is stored in a database.

This package provides classes to implement model objects that can also generate audit logs for each type of change that is performed on application data objects that are stored in a database.

Manuel Lemos
Picture of Ruturaj Maniyar
  Performance   Level  
Name: Ruturaj Maniyar <contact>
Classes: 2 packages by
Country: India India
Age: 29
All time rank: 2768171 in India India
Week rank: 136 15 in India India
Innovation award
Innovation award
Nominee: 2x

Details

ruturajmaniyar/yii2-audit-log

Yii2 audit record and database changes details

Installation

The preferred way to install this extension is through composer.

Either run

composer require --prefer-dist ruturajmaniyar/yii2-audit-log:"dev-master"

or

php composer.phar require --prefer-dist ruturajmaniyar/yii2-audit-log:"dev-master"

or add

"ruturajmaniyar/yii2-audit-log": "dev-master"

to the require section of your composer.json file.

Migration

To run migration to create "tbl_audit_entry" table in your db.

php yii migrate/up --migration-path "@vendor/ruturajmaniyar/yii2-audit-log/src/migrations/"

or

you can also import "tbl_audit_entry.sql" directly in your DB.

Module

Add Audit Entry module in your config file

....
'modules' => [
    ......
    'auditlog' => [
                'class' => 'ruturajmaniyar\mod\audit\AuditEntryModule'
    ],
    ......
],
....

Component

Add DateTimeHelper components in your config file

....
'components' => [
    ......
    'dateTimeConversion' => [
                'class' => 'ruturajmaniyar\mod\audit\components\DateTimeHelper'
    ],
    ......
],
....

Usage

Use get audit log activities or records, attached "AuditEntryBehaviors" with your models as belows:

use ruturajmaniyar\mod\audit\behaviors\AuditEntryBehaviors;
use yii\db\ActiveRecord;

class User extends ActiveRecord {

    public function behaviors(){
        return [ 
            ....
            'auditEntryBehaviors' => [
                'class' => AuditEntryBehaviors::class
             ],
             ....
        ];
    }
}
  Files  
File Role Description
src (1 file, 6 directories)
composer.json Data Auxiliary data
LICENSE.md Lic. License text
README.md Doc. Documentation

  Files  /  src  
File Role Description
behaviors (1 file)
components (1 file)
controllers (1 file)
migrations (2 files)
models (2 files)
views (1 directory)
   AuditEntryModule.php Class Class source

  Files  /  src  /  behaviors  
File Role Description
   AuditEntryBehaviors.php Class Class source

  Files  /  src  /  components  
File Role Description
   DateTimeHelper.php Class Class source

  Files  /  src  /  controllers  
File Role Description
   AuditEntryController.php Class Class source

  Files  /  src  /  migrations  
File Role Description
   m190612_092611_tbl_audit_entry.php Class Class source
   tbl_audit_entry.sql Data Auxiliary data

  Files  /  src  /  models  
File Role Description
   AuditEntry.php Class Class source
   AuditEntrySearch.php Class Class source

  Files  /  src  /  views  
File Role Description
audit-entry (2 files)

  Files  /  src  /  views  /  audit-entry  
File Role Description
   index.php Example Example script
   _search.php Example Example script

 Version Control Unique User Downloads Download Rankings  
 100%
Total:83
This week:0
All time:9,540
This week:373

For more information send a message to info at phpclasses dot org.