PHPackages                             vikilaboy/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. vikilaboy/yii2-activerecord-history

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

vikilaboy/yii2-activerecord-history
===================================

This extension adds storage history of changes to the ActiveRecord model.

1.1.1(7y ago)013BSD-3-ClausePHP

Since Jan 3Pushed 7y agoCompare

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

READMEChangelogDependencies (4)Versions (4)Used By (0)

yii2-activerecord-history
=========================

[](#yii2-activerecord-history)

[![Latest Stable Version](https://camo.githubusercontent.com/785f45f03be1896ddbdd293bfb50dbfa49d228c078a13d09416519096bb7d7a0/68747470733a2f2f706f7365722e707567782e6f72672f62757079372f796969322d6163746976657265636f72642d686973746f72792f762f737461626c65)](https://packagist.org/packages/bupy7/yii2-activerecord-history)[![Total Downloads](https://camo.githubusercontent.com/645560b6d3338330522fd649343fb3ffa3d4dc6b3d5dc6d9e937f79179a12b47/68747470733a2f2f706f7365722e707567782e6f72672f62757079372f796969322d6163746976657265636f72642d686973746f72792f646f776e6c6f616473)](https://packagist.org/packages/bupy7/yii2-activerecord-history)[![Latest Unstable Version](https://camo.githubusercontent.com/a42002d0c571c1a4d1ef956feec4b6a78dc25a75fd97a28efff110b45061e68e/68747470733a2f2f706f7365722e707567782e6f72672f62757079372f796969322d6163746976657265636f72642d686973746f72792f762f756e737461626c65)](https://packagist.org/packages/bupy7/yii2-activerecord-history)[![License](https://camo.githubusercontent.com/0eb802ac5e6b74931603cbd43ca3441531aef07526fcab7a819f662937084afa/68747470733a2f2f706f7365722e707567782e6f72672f62757079372f796969322d6163746976657265636f72642d686973746f72792f6c6963656e7365)](https://packagist.org/packages/bupy7/yii2-activerecord-history)[![Build Status](https://camo.githubusercontent.com/2b4323ee7a644e3dd3a5a9d0cf9f3b0ef220921bead03aa594814e6b0d8cb6cf/68747470733a2f2f7472617669732d63692e6f72672f62757079372f796969322d6163746976657265636f72642d686973746f72792e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/bupy7/yii2-activerecord-history)[![Coverage Status](https://camo.githubusercontent.com/999ee9de984d58b55072c78f1fdca94175e085e77a768fda8b82de06ed3d2c7b/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f62757079372f796969322d6163746976657265636f72642d686973746f72792f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/bupy7/yii2-activerecord-history?branch=master)

This extension adds storage history of changes to the ActiveRecord model.

Extension can tacking changes to model and save to storage. Allowed only storage to database. All changes saved to table in database.

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

[](#installation)

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

Either run

```
php composer.phar require --prefer-dist bupy7/yii2-activerecord-history "*"

```

or add

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

```

to the require section of your `composer.json` file.

Usage
-----

[](#usage)

> NOTICE! Configuration of module must have in `common/config/main.php` if you will use `andanced` template. Or add configuration in both `config/web.php` and `config/console.php` if you will use `basic` template.

**Register of module to config file:**

```
'modules' => [
    'arhistory' => [
        'class' => 'bupy7\activerecord\history\Module',
    ],
],
```

Name of module can be any (example: history, custom-name and etc).

**Add module in bootstrap to config file:**

```
'bootstrap' => ['arhistory'],
```

**Run migration:**

```
php ./yii migrate/up --migrationPath=@bupy7/activerecord/history/migrations
```

**Attach behavior to model:**

```
use bupy7\activerecord\history\behaviors\History as HistoryBehavior;

$model->attachBehavior('arHistory', HistoryBehavior::className());
```

Configuration
-------------

[](#configuration)

**Module configuration:**

```
'modules' => [
    'arhistory' => [
        'class' => 'bupy7\activerecord\history\Module',
        'tableName' => '{{%arhistory}}', // table name of saving changes of model
        'storage' => 'bupy7\activerecord\history\storages\Database', // class name of storage for saving history of active record model
        'db' => 'db', // database connection component config or name
        'user' => 'user', // authentication component config or name
    ],
],
```

**Behavior configuration:**

```
use bupy7\activerecord\history\behaviors\History as HistoryBehavior;

$model->attachBehavior('arHistory', [
    'class' => HistoryBehavior::className(),
    // allowed events list than are monitored and saved in storage.
    'allowEvents' => [
        HistoryBehavior::EVENT_INSERT,
        HistoryBehavior::EVENT_UPDATE,
        HistoryBehavior::EVENT_DELETE,
    ],
    // list of attributes which not need track at updating. Apply only for `HistoryBehavior::EVENT_UPDATE`.
    'skipAttributes' => [
        'name_of_attribute_1',
        'name_of_attribute_2',
    ],
    // list of custom attributes which which are a pair of `key`=>`value` where `key` is attribute name and
    // `value` it anonymous callback function of attribute. Function will be apply for old and value information data.
    // Apply only for `HistoryBehavior::EVENT_UPDATE`.
    'customAttributes' => [
        'name_of_attribute_3' => function($event, $isNewValue) {
            if ($isNewValue) {
                return $event->sender->name_of_attribute_3;
            }
            return $event->changedAttributes['name_of_attribute_3'];
        },
    ],
]);
```

License
-------

[](#license)

yii2-activerecord-history is released under the BSD 3-Clause License.

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 77.3% 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 ~441 days

Total

3

Last Release

2899d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/2757887?v=4)[El Niño](/maintainers/vikilaboy)[@vikilaboy](https://github.com/vikilaboy)

---

Top Contributors

[![bupy7](https://avatars.githubusercontent.com/u/5145037?v=4)](https://github.com/bupy7 "bupy7 (34 commits)")[![vikilaboy](https://avatars.githubusercontent.com/u/2757887?v=4)](https://github.com/vikilaboy "vikilaboy (9 commits)")[![cybernic](https://avatars.githubusercontent.com/u/5999069?v=4)](https://github.com/cybernic "cybernic (1 commits)")

---

Tags

modelhistorychangesyii2extensionmoduleBehavioractiverecord

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

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

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

###  Alternatives

[nhkey/yii2-activerecord-history

Storage history of changes to ActiveRecord

46143.4k1](/packages/nhkey-yii2-activerecord-history)[sjaakp/yii2-sortable-behavior

Sort ActiveRecords and related records in Yii2.

36144.7k](/packages/sjaakp-yii2-sortable-behavior)[nanson/yii2-postgis

Yii2-extension to work with postgis data

1851.6k](/packages/nanson-yii2-postgis)

PHPackages © 2026

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