PHPackages                             tigrov/yii2-pgsql-audit - 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. tigrov/yii2-pgsql-audit

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

tigrov/yii2-pgsql-audit
=======================

Audit for ActiveRecord models for Yii2, for PostgreSQL only

1.3.5(6y ago)0491MITPHPPHP &gt;=5.5.0

Since May 30Pushed 6y ago1 watchersCompare

[ Source](https://github.com/Tigrov/yii2-pgsql-audit)[ Packagist](https://packagist.org/packages/tigrov/yii2-pgsql-audit)[ RSS](/packages/tigrov-yii2-pgsql-audit/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (2)Versions (13)Used By (0)

yii2-pgsql-audit
================

[](#yii2-pgsql-audit)

Audit for ActiveRecord models for Yii2, for PostgreSQL only.

The extension is used as a behavior for an ActiveRecord model. It will store all changes for the model and gives you possibility to review the changes and revert them.

[![Latest Stable Version](https://camo.githubusercontent.com/ccda12927116a3d824a679497f633957d20bd49f73859396740e4eb45b9b1a1b/68747470733a2f2f706f7365722e707567782e6f72672f546967726f762f796969322d706773716c2d61756469742f762f737461626c65)](https://packagist.org/packages/Tigrov/yii2-pgsql-audit)[![Build Status](https://camo.githubusercontent.com/cb62628216c2568fe87636bde66b744b739fa603b59cd39ed38ae025ac2d2d73/68747470733a2f2f7472617669732d63692e6f72672f546967726f762f796969322d706773716c2d61756469742e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/Tigrov/yii2-pgsql-audit)

Limitation
----------

[](#limitation)

It is for PostgreSQL only.

The extension optimized for `integer` type of `\Yii::$app->user->id`
and for `ActiveRecord` models with `integer` type of **primary key**.

If you have different of `integer` types, you can inherit the classes and make the necessary changes. Also you need to make changes in the audit table schema.

- Since 1.2.0 requires PHP &gt;= 5.5
- Since 1.3.0 requires Yii &gt;= 2.0.14.2

Dependents
----------

[](#dependents)

The extension depends on follow extensions:

- [Tigrov/yii2-pgsql-enum](https://github.com/Tigrov/yii2-pgsql-enum)

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

[](#installation)

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

Either run

```
php composer.phar require --prefer-dist tigrov/yii2-pgsql-audit

```

or add

```
"tigrov/yii2-pgsql-audit": "~1.0"

```

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

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

[](#configuration)

Once the extension is installed, configure migrations in `config.php`:

```
return [
    // ...
    'controllerMap' => [
        'migrate' => [
            'class' => 'yii\console\controllers\MigrationController',
        ],
    ],
    // ...
];
```

and apply migrations:

```
yii migrate

```

Usage
-----

[](#usage)

Add the behavior `AuditableBehavior` to a model class.

```
class Model extends \yii\db\ActiveRecord
{
    public function behaviors()
    {
        return [
            AuditableBehavior::class,
        ];
    }
}
```

Some examples how you can use it:

```
$model = new Model;
$model->value = 'a value';
$model->save();

$model->createdAt; // created date and time
$model->createdBy; // instance of \Yii::$app->user->identityClass

// then update it
$model->value = 'new value';
$model->save();

$model->updatedAt; // updated date and time
$model->updatedBy; // instance of \Yii::$app->user->identityClass

// additional features
$model->firstAudit; // \tigrov\pgsql\audit\Audit
$model->lastAudit; // \tigrov\pgsql\audit\Audit

$model->lastAudit->model; // ActiveRecord
$model->lastAudit->user; // instance of \Yii::$app->user->identityClass

$model->lastAudit->revert(); // revert the last changes
$model->firstAudit->revert(); // revert to the first model version

Audit::findByModel($model); // ActiveQuery, to get audit records for the model
Audit::findByUserId($userId); // ActiveQuery, to get audit records for a user
```

License
-------

[](#license)

[MIT](LICENSE)

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity65

Established project with proven stability

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

Total

12

Last Release

2461d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/77d285672dec831b7ce5746ab8bb1dd20fffe81fb9d11c232534686706de9697?d=identicon)[Tigros](/maintainers/Tigros)

---

Top Contributors

[![Tigrov](https://avatars.githubusercontent.com/u/8563175?v=4)](https://github.com/Tigrov "Tigrov (22 commits)")

---

Tags

auditpgsqlpostgrespostgresqlyii2-extensionpostgresqlpostgrespgsqlAudityii2extension

### Embed Badge

![Health badge](/badges/tigrov-yii2-pgsql-audit/health.svg)

```
[![Health](https://phpackages.com/badges/tigrov-yii2-pgsql-audit/health.svg)](https://phpackages.com/packages/tigrov-yii2-pgsql-audit)
```

###  Alternatives

[tigrov/yii2-pgsql

Improved PostgreSQL schemas for Yii2

3467.0k](/packages/tigrov-yii2-pgsql)[martin-georgiev/postgresql-for-doctrine

Extends Doctrine with native PostgreSQL support for arrays, JSONB, ranges, PostGIS geometries, text search, ltree, uuid, and 100+ PostgreSQL-specific functions.

4485.3M4](/packages/martin-georgiev-postgresql-for-doctrine)[aura/sql

A PDO extension that provides lazy connections, array quoting, query profiling, value binding, and convenience methods for common fetch styles. Because it extends PDO, existing code that uses PDO can use this without any changes to the existing code.

5632.5M43](/packages/aura-sql)[aura/sqlquery

Object-oriented query builders for MySQL, Postgres, SQLite, and SQLServer; can be used with any database connection library.

4572.9M34](/packages/aura-sqlquery)[nanson/yii2-postgis

Yii2-extension to work with postgis data

1851.6k](/packages/nanson-yii2-postgis)[umbrellio/laravel-pg-extensions

Extensions for Postgres Laravel

102426.5k1](/packages/umbrellio-laravel-pg-extensions)

PHPackages © 2026

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