PHP Classes
elePHPant
Icontem

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

Recommend this page to a friend!
  Info   View files Documentation   View files View files (13)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2019-07-04 (27 days ago) RSS 2.0 feedNot yet rated by the usersTotal: 44 This week: 2All time: 9,585 This week: 104Up
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
Nominee
Vote
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
  Performance   Level  
Name: Ruturaj Maniyar <contact>
Classes: 2 packages by
Country: 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 folder image Files  
File Role Description
Files folder imagesrc (1 file, 6 directories)
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file LICENSE.md Lic. License text
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files  /  src  
File Role Description
Files folder imagebehaviors (1 file)
Files folder imagecomponents (1 file)
Files folder imagecontrollers (1 file)
Files folder imagemigrations (2 files)
Files folder imagemodels (2 files)
Files folder imageviews (1 directory)
  Plain text file AuditEntryModule.php Class Class source

  Files folder image Files  /  src  /  behaviors  
File Role Description
  Plain text file AuditEntryBehaviors.php Class Class source

  Files folder image Files  /  src  /  components  
File Role Description
  Plain text file DateTimeHelper.php Class Class source

  Files folder image Files  /  src  /  controllers  
File Role Description
  Plain text file AuditEntryController.php Class Class source

  Files folder image Files  /  src  /  migrations  
File Role Description
  Plain text file m190612_092611_tbl_audit_entry.php Class Class source
  Accessible without login Plain text file tbl_audit_entry.sql Data Auxiliary data

  Files folder image Files  /  src  /  models  
File Role Description
  Plain text file AuditEntry.php Class Class source
  Plain text file AuditEntrySearch.php Class Class source

  Files folder image Files  /  src  /  views  
File Role Description
Files folder imageaudit-entry (2 files)

  Files folder image Files  /  src  /  views  /  audit-entry  
File Role Description
  Accessible without login Plain text file index.php Example Example script
  Accessible without login Plain text file _search.php Example Example script

 Version Control Unique User Downloads Download Rankings  
 100%
Total:44
This week:2
All time:9,585
This week:104Up