pvsaintpe / yii2-log
Package
Requires
- php: ^7.1.3
- pvsaintpe/yii2-behaviors: *
- pvsaintpe/yii2-db-plus: *
- pvsaintpe/yii2-search: 5.*
- yiisoft/yii2: 2.0.*
- yiisoft/yii2-authclient: 2.*
- yiisoft/yii2-bootstrap: 2.*
- yiisoft/yii2-imagine: 2.*
This package is auto-updated.
Last update: 2026-06-09 08:20:02 UTC
README
Installation
The preferred way to install this extension is through composer.
Check the composer.json for this extension's requirements and dependencies. Read this web tip /wiki on setting the minimum-stability settings for your application's composer.json. Either run
$ php composer.phar require pvsaintpe/yii2-log "8.*"
or add
"pvsaintpe/yii2-log": "8.*"
to the require section of your composer.json file.
Additional information
All base models and query must be inherited from:
ActiveRecord extends \pvsaintpe\log\components\ActiveRecord
ActiveQuery extends \pvsaintpe\log\components\ActiveQuery
To track changes, add to your model:
/** * @return bool */ public static function logEnabled() { return true; }
Build project
Every time when you change the database schema to be logged, run the command:
#!/usr/bin/env bash
php ./yii changelog/generate
php ./yii changelog/migrate --interactive=0
Customization
- To access the visual part, for example, to view revisions and change history of your data, add to the config:
// backend/configs/main.php return [ 'modules' => [ 'changelog' => [ 'class' => 'pvsaintpe\log\Module', ], ] ];
- To fine-tune the logging system, use the configurator. For a complete list of available options, see pvsaintpe\log\components\Configs:
// common/configs/params.php return [ 'changelog.configs' => [ 'db' => 'dbLog', // DB Storage for Log-tables 'storageDb' => 'db', // DB Storage for Data-tables 'adminTable' => 'admin', // Table Name for Admin's 'tablePrefix' => '_log', 'adminColumn => 'updated_by', ], ];
Usage
To activate all features of the component, use pvsaintpe\log\traits\SearchTrait in your Search-models. It is recommended to keep the log data in a separate database, although you are not limited in this.