Download the PHP package sammaye/yii2-audittrail without Composer
On this page you can find all versions of the php package sammaye/yii2-audittrail. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download sammaye/yii2-audittrail
More information about sammaye/yii2-audittrail
Files in sammaye/yii2-audittrail
Informations about the package yii2-audittrail
yii2-audittrail
Yii2 edition of the audittrail extension.
Installation
The preferred way to install this extension is through composer.
Migration
There are two ways of doing this:
- Copy the migration file (within the
migrations
folder) to yourconsole/migrations
folder - Run
php yii migrate --migrationPath=@vendor/sammaye/yii2-audittrail/migrations
How to use
To use this extension you can simply add it to the model's behaviours:
You can convert the entered behaviour into a key - value structure to define options for the extension for that model:
And that is basically how to setup this extension.
Changes
There are a couple of changes.
One of them is how to define global parameters for this extension.
An example of global parameters would be setting you own table name or defining the location of the user model.
To define your own table you can add a parameter to your params.php
file called audittrail.table
which would take something like {{%audit}}
.
To define your own user model location you can add audittrail.model
using a value like common\models\User
.
The only other change is really to do with the best way to query the audit trail.
The below example is the one from the previous documentation rewritten for Yii2:
Notice the:
This allows us to get the name of the model without the namespace part on it.
Currently in this extension I store the fully qualified name of the class to:
- Take advantage of namespacing to create uniqueness
- To make it easier to query using the
className()
function in Objects.