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

ActiveLibrary[Database &amp; ORM](/categories/database)

cusodede/yii2-history
=====================

The history of all changes in ActiveRecord models

1.1.3(3y ago)5331[1 issues](https://github.com/cusodede/yii2-history/issues)LGPL-3.0-or-laterPHPPHP &gt;=8.0

Since Feb 17Pushed 3y ago1 watchersCompare

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

READMEChangelogDependencies (17)Versions (9)Used By (0)

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

[](#yii2-history)

The history of all changes in ActiveRecord models

[![Build Status](https://github.com/cusodede/yii2-history/actions/workflows/ci.yml/badge.svg)](https://github.com/cusodede/yii2-history/actions)

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

[](#installation)

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

Run

```
php composer.phar require cusodede/yii2-history "^1.0.0"

```

or add

```
"cusodede/yii2-history": "^1.0.0"

```

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

Requirements
------------

[](#requirements)

Yii2, PHP &gt;= 8.0

Usage
-----

[](#usage)

At first, run module migrations:

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

```

Connect `cusodede\history\behaviors\HistoryBehavior::class` to all `ActiveRecord` models, that require to store their history:

```
public function behaviors():array {
	return [
		'history' => [
			'class' => HistoryBehavior::class
		]
	];
}
```

If you want to get the user interface and/or change default module configuration, you need to setup the module in the application config:

```
$config = [
	...
	'modules' => [
		'history' => [
			'class' => HistoryModule::class,
		]
	],
	...
]
```

Module configuration
--------------------

[](#module-configuration)

There are all the module parameters with their default values:

```
$config = [
	...
	'modules' => [
		'history' => [
			'class' => HistoryModule::class,
			'params' => [
				'userIdentityClass' => Yii::$app->user->identityClass,
				'viewPath' => '@vendor/cusodede/yii2-history/src/views/default'
				'queue' => null,
				'storeShortClassNames' => false
			]
		]
	],
	...
]
```

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:

```
$config = [
	...
	'modules' => [
		'history' => [
			'class' => HistoryModule::class,
			'params' => [
				'queue' => [
					'class' => Queue::class,
				]
			]
		]
	],
	...
]
```

Also, you can use any queues, that already configured in your application. For that case just provide string queue name:

```
$config = [
	...
	'components' => [
		'common-queue' => [
			'class' => Queue::class,
		]
	]
	'modules' => [
		'history' => [
			'class' => HistoryModule::class,
			'params' => [
				'queue' => 'common-queue'
			]
		]
	],
	...
]
```

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
-------------------

[](#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:
--------------------

[](#documentation-todos)

- History format;
- History tags;
- History widgets;
- Delegates support;

License
-------

[](#license)

GNU GPL v3.0

###  Health Score

26

—

LowBetter than 41% of packages

Maintenance16

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity56

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 ~7 days

Total

8

Last Release

1182d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/2357892?v=4)[Pavel Dubrovsky](/maintainers/pozitronik)[@pozitronik](https://github.com/pozitronik)

---

Top Contributors

[![pozitronik](https://avatars.githubusercontent.com/u/2357892?v=4)](https://github.com/pozitronik "pozitronik (150 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[craftcms/cms

Craft CMS

3.6k3.6M3.0k](/packages/craftcms-cms)[bavix/laravel-wallet

It's easy to work with a virtual wallet.

1.3k1.3M19](/packages/bavix-laravel-wallet)[leantime/leantime

Open source project management system for non-project managers. Simple like Trello, powerful like Jira. Built with neurodiversity in mind.

10.1k3.5k](/packages/leantime-leantime)[google/cloud-bigquery

BigQuery Client for PHP

8919.2M53](/packages/google-cloud-bigquery)[patchlevel/event-sourcing

A lightweight but also all-inclusive event sourcing library with a focus on developer experience

207362.9k13](/packages/patchlevel-event-sourcing)[markocupic/calendar-event-booking-bundle

Contao Calendar Event Booking Bundle

135.2k1](/packages/markocupic-calendar-event-booking-bundle)

PHPackages © 2026

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