vsevolod-ryzhov / yii2-ar-logger
Yii2 ActiveRecord changes logger
Installs: 1
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:yii2-extension
Requires
- php: >=7.1
- ext-json: *
- yiisoft/yii2: *
Requires (Dev)
- phpunit/phpunit: ~4.0
This package is auto-updated.
Last update: 2025-03-29 00:48:31 UTC
README
Log change of Yii2 AR models
Installation
Via Composer
composer require vsevolod-ryzhov/yii2-ar-logger
Logs storage
You can install migration to store data in your database:
php yii migrate --migrationPath=@vendor/vsevolod-ryzhov/yii2-ar-logger/src/migrations
or you can use your own storage data class, which should implement ArLoggerStorageInterface interface
Usage
Update your ActiveRecord class:
- if you use the built-in class DbLoggerStorage
public function behaviors() { return [ ... [ 'class' => ArLoggerBehavior::class, 'excludedAttributes' => ['created_at', 'updated_at'], ], ... ]; }
- if you want to use your own storage:
// create your own storage class class MyOwnStorage implements ArLoggerStorageInterface { public function store(ArLoggerObject $object): bool { // save $object here return true; } } // pass storage class to behavior param "storage" public function behaviors() { return [ ... [ 'class' => ArLoggerBehavior::class, 'storage' => MyOwnStorage::class, 'excludedAttributes' => ['created_at', 'updated_at'], ], ... ]; }