PHPackages                             kirillemko/yii2-activerecord-history - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. kirillemko/yii2-activerecord-history

ActiveYii2-extension[Database &amp; ORM](/categories/database)

kirillemko/yii2-activerecord-history
====================================

Save history of changes of ActiveRecord model

2.1.4(1y ago)03961PHP

Since Mar 21Pushed 1y ago1 watchersCompare

[ Source](https://github.com/kirillemko/yii2-activerecord-history)[ Packagist](https://packagist.org/packages/kirillemko/yii2-activerecord-history)[ RSS](/packages/kirillemko-yii2-activerecord-history/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (1)Versions (16)Used By (0)

Yii2 ActiveRecord History behavior for Yii 2
============================================

[](#yii2-activerecord-history-behavior-for-yii-2)

Installation
------------

[](#installation)

The preferred way to install this extension is through [composer](http://getcomposer.org/download/).

Either run

```
composer require kirillemko/yii2-activerecord-history

```

or add

```
"kirillemko/yii2-activerecord-history": "*"

```

to the require section of your composer.json.

Run migration

```
php yii migrate --migrationPath=@vendor/kirillemko/yii2-activerecord-history/migrations

```

Использование
-------------

[](#использование)

Поведение позволяет писать историю изменения модели. Просто добавьте ее в модель в метод behaviors:

```
public function behaviors() {
    return [
        ...
        [ 'class' => ActiveRecordHistoryBehavior::class ]

```

Возможны следующие параметры конфигурации:

```
Поставить в true, если при создании модели нужно записать все поля в историю.
В противном случае пишется только сам факт создания модели
'saveFieldsOnInsert' => false

Массив полей, изменение которых не нужно писать.
Например при использовании 'created_at'
'ignoreFields' => []

Конфигурация отслеживаемых евентов.
Можно отключить евент, если не нужно писать
'watchInsertEvent' => true,
'watchUpdateEvent' => true,
'watchDeleteEvent' => true

```

Также поведение предоставляет метод для получения истории изменений

```
$someModel->getChangesHistory($sortAsc = true);

```

Будет возвращен массив объектов kirillemko\\activeRecordHistory\\models\\ActiveRecordHistory

При приведении объекта к массиву будут два дополнительных свойства type\_full\_name и field\_full\_name для удобства подстановки на фронте. Пример:

```
{
    "id": 10,
    "user_id": 1,
    "type": 2,
    "model": "App\\domain\\ACL\\models\\AclGroupsPermissions",
    "model_id": "21",
    "field_name": "desc",
    "old_value": "Описание объекта",
    "new_value": "Новое описание объекта",
    "created_at": 1625908836,
    "field_full_name": "Описание",
    "type_full_name": "Редактирование"
}

```

В данном объекте в свойстве field\_full\_name реализовано получение человеческого названия из attributesLabel таргет модели

TODO
----

[](#todo)

У объекта kirillemko\\activeRecordHistory\\models\\ActiveRecordHistory дополнительное свойство type\_full\_name сделать через i18n, а не хардкод

Credits
-------

[](#credits)

Authors: Kirill Emelianenko

Email:

###  Health Score

35

—

LowBetter than 77% of packages

Maintenance48

Moderate activity, may be stable

Popularity15

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~84 days

Recently: every ~124 days

Total

15

Last Release

382d ago

Major Versions

1.0.5 → 2.0.12022-05-31

### Community

Maintainers

![](https://www.gravatar.com/avatar/eed5ea0d1633eceef18c38b3b86451a0856c8853df57a3872ff56afc971320f5?d=identicon)[kirillemko](/maintainers/kirillemko)

---

Top Contributors

[![kirillemko](https://avatars.githubusercontent.com/u/7727765?v=4)](https://github.com/kirillemko "kirillemko (25 commits)")

---

Tags

historyyii2activerecord

### Embed Badge

![Health badge](/badges/kirillemko-yii2-activerecord-history/health.svg)

```
[![Health](https://phpackages.com/badges/kirillemko-yii2-activerecord-history/health.svg)](https://phpackages.com/packages/kirillemko-yii2-activerecord-history)
```

###  Alternatives

[craftcms/cms

Craft CMS

3.6k3.6M3.1k](/packages/craftcms-cms)[nhkey/yii2-activerecord-history

Storage history of changes to ActiveRecord

46148.8k1](/packages/nhkey-yii2-activerecord-history)[yii-dream-team/yii2-lockable-activerecord

Pessimistic locking behavior for Yii2 ActiveRecord

1888.8k](/packages/yii-dream-team-yii2-lockable-activerecord)[spinitron/yii2-dynamic-ar

Extends Yii ActiveRecord for Maria Dynamic Columns

577.0k](/packages/spinitron-yii2-dynamic-ar)[jlorente/yii2-activerecord-inheritance

ActiveRecord Inheritance is an util to provide the Class Table Inheritance Pattern the to the Yii2 framework. It fakes inheritance between two ActiveRecord classes.

184.2k](/packages/jlorente-yii2-activerecord-inheritance)[execut/yii2-1c-odata

Yii2 component for work with 1C oData via activeRecord

101.5k](/packages/execut-yii2-1c-odata)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
