Download the PHP package cusodede/yii2-history without Composer
On this page you can find all versions of the php package cusodede/yii2-history. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download cusodede/yii2-history
More information about cusodede/yii2-history
Files in cusodede/yii2-history
Package yii2-history
Short Description The history of all changes in ActiveRecord models
License LGPL-3.0-or-later
Informations about the package yii2-history
yii2-history
The history of all changes in ActiveRecord models
Installation
The preferred way to install this extension is through composer.
Run
or add
to the require section of your composer.json
file.
Requirements
Yii2, PHP >= 8.0
Usage
At first, run module migrations:
Connect cusodede\history\behaviors\HistoryBehavior::class
to all ActiveRecord
models, that require to store their history:
If you want to get the user interface and/or change default module configuration, you need to setup the module in the application config:
Module configuration
There are all the module parameters with their default values:
Parameters description:
userIdentityClass: null
|string
|callable
. The module tries to store some user ID with the each history record, so it is required to
provide proper user identity object. In most cases, that object is already configured in framework (and can be accessed
via Yii::$app->user
), but in some cases (like in console applications) it is not. It also can be overridden in some cases, so it's useful
to have option, like that.
viewPath: string
. The module has a basic user interface for navigating histories. You may want to get your own custom interface for
that, so you can provide path to custom views here.
queue: null
|string
|array
. The proper way to make all history writings asynchronous, is to push them to a queue. The queue
parameter allow you to configure own module queue. Just configure it like as in global configuration:
Also, you can use any queues, that already configured in your application. For that case just provide string queue name:
If parameter is skipped or set to null, all writings will be made synchronously, which may affect on the application speed.
storeShortClassNames: bool
. Experimental option, that allows to store only short class name instead of fully qualified namespace
(example: Users
instead of app\models\Users
).
Running local tests
Copy /tests/.env.sample
to /tests/.env
(change variables there, if it required in your environment) and
run composer install
(once) and php vendor/bin/codecept run
(to execute tests).
For Docker environment, you can just execute docker-compose up -d --build
command to build app containers,
then run docker exec -it yii2_history_php /bin/bash
to open bash console inside php container. Next, just do as written above.
Documentation ToDos:
- History format;
- History tags;
- History widgets;
- Delegates support;
License
GNU GPL v3.0
All versions of yii2-history with dependencies
pozitronik/yii2-traits Version ^1.0.0
pozitronik/yii2-badgewidget Version ^2.0.0
ramsey/uuid Version ^4.0.0
yiisoft/yii2 Version ^2.0.0
yiisoft/yii2-queue Version ^2.0.0