PHPackages                             olegf13/yii2-mongorevision-behavior - 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. olegf13/yii2-mongorevision-behavior

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

olegf13/yii2-mongorevision-behavior
===================================

MongoRevision behavior for Yii 2

0.2.0(9y ago)0231MITPHP

Since Feb 4Pushed 9y ago1 watchersCompare

[ Source](https://github.com/Olegf13/yii2-mongorevision-behavior)[ Packagist](https://packagist.org/packages/olegf13/yii2-mongorevision-behavior)[ Docs](https://github.com/olegf13/yii2-mongorevision-behavior)[ RSS](/packages/olegf13-yii2-mongorevision-behavior/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (1)Dependencies (2)Versions (3)Used By (0)

MongoRevision behavior for Yii 2
================================

[](#mongorevision-behavior-for-yii-2)

This behavior provides automatic revision creation of any ActiveRecord object(s) into MongoDB collection.

It means, that the extension will automatically save "previous version" of your ActiveRecord object after it's been updated.

So you can store and track the history of all your data changes.

To describe in detail, MongoRevision behavior will collect "old" AR object attributes, fill the `revisionOwnerId`, `revisionOwnerModel`, `revisionDate` and `revisionUser` attributes with the corresponding values; and then store the resulting AR object revision in particular MongoDB `revision` collection.

Behavior is called after the associated AR object is being updated (EVENT\_AFTER\_UPDATE).

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

[](#installation)

This extension requires [MongoDb Extension for Yii 2](https://github.com/yiisoft/yii2-mongodb).

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

Either run

```
php composer.phar require --prefer-dist olegf13/yii2-mongorevision-behavior "*"

```

or add

```
"olegf13/yii2-mongorevision-behavior": "*"

```

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

Usage
-----

[](#usage)

To use MongoRevisionBehavior, insert the following code to your ActiveRecord class:

```
use olegf13\mongorevision\MongoRevisionBehavior;
// ...
public function behaviors()
{
    return [
        MongoRevisionBehavior::className(),
    ];
}
```

If your MongoDB connection name is different or you want to use a different collection or attribute names, you may configure behavior properties like the following:

```
use olegf13\mongorevision\MongoRevisionBehavior;
// ...
public function behaviors()
{
    return [
        [
            'class' => MongoRevisionBehavior::className(),
            'mongoConnectionName' => 'mongodb',
            'mongoCollection' => 'revision',
            'revisionOwnerIdAttribute' => 'ownerId',
            'revisionOwnerModelAttribute' => 'ownerModel',
            'revisionDateAttribute' => 'revisionDate',
            'revisionUserAttribute' => 'revisionUser',
        ],
    ];
}
```

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 50% 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 ~155 days

Total

2

Last Release

3595d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/5ac3d55738e21a2f2a55215a403ac838c9293f6b3457396215a8d553fbb21035?d=identicon)[Olegf13](/maintainers/Olegf13)

---

Top Contributors

[![ApexWire](https://avatars.githubusercontent.com/u/2697129?v=4)](https://github.com/ApexWire "ApexWire (2 commits)")[![Olegf13](https://avatars.githubusercontent.com/u/2501447?v=4)](https://github.com/Olegf13 "Olegf13 (2 commits)")

---

Tags

versioningrevisionmongodbyii2extensionBehaviormongovcs

### Embed Badge

![Health badge](/badges/olegf13-yii2-mongorevision-behavior/health.svg)

```
[![Health](https://phpackages.com/badges/olegf13-yii2-mongorevision-behavior/health.svg)](https://phpackages.com/packages/olegf13-yii2-mongorevision-behavior)
```

###  Alternatives

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