PHPackages                             yiier/yii2-humans-log - 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. [Logging &amp; Monitoring](/categories/logging)
4. /
5. yiier/yii2-humans-log

ActiveYii2-extension[Logging &amp; Monitoring](/categories/logging)

yiier/yii2-humans-log
=====================

人类能看得懂的操作日志

v1.3.1(6y ago)63601BSD-4-ClausePHP

Since Dec 6Pushed 6y ago4 watchersCompare

[ Source](https://github.com/yiier/yii2-humans-log)[ Packagist](https://packagist.org/packages/yiier/yii2-humans-log)[ RSS](/packages/yiier-yii2-humans-log/feed)WikiDiscussions master Synced yesterday

READMEChangelog (10)Dependencies (1)Versions (12)Used By (0)

Log for Humans for Yii2
=======================

[](#log-for-humans-for-yii2)

人类能看得懂的操作日志

[![Latest Stable Version](https://camo.githubusercontent.com/54e6752b88ef667438b145f36e82ac4158a3712592549a3c0b15cface4333b44/68747470733a2f2f706f7365722e707567782e6f72672f79696965722f796969322d68756d616e732d6c6f672f762f737461626c65)](https://packagist.org/packages/yiier/yii2-humans-log)[![Total Downloads](https://camo.githubusercontent.com/049496c439e9fd0f3154db6cabf9fcffcc83a3af491cc252b569447ab4322989/68747470733a2f2f706f7365722e707567782e6f72672f79696965722f796969322d68756d616e732d6c6f672f646f776e6c6f616473)](https://packagist.org/packages/yiier/yii2-humans-log)[![Latest Unstable Version](https://camo.githubusercontent.com/d76e40a3f1149759328436377b2f6ce2faed007b85ee95865dbe8511cb12ad7f/68747470733a2f2f706f7365722e707567782e6f72672f79696965722f796969322d68756d616e732d6c6f672f762f756e737461626c65)](https://packagist.org/packages/yiier/yii2-humans-log)[![License](https://camo.githubusercontent.com/d80016d507d287cdbff35bc60a7786ace6b3927795c2bdde5b81e0dee7dcf08f/68747470733a2f2f706f7365722e707567782e6f72672f79696965722f796969322d68756d616e732d6c6f672f6c6963656e7365)](https://packagist.org/packages/yiier/yii2-humans-log)

Description
-----------

[](#description)

- 此扩展只要你按照约定的规则，可以帮你记录操作日志。
- 只能监控单条数据，所以不适用于需要操作多条数据。
- 无法做到颗粒度很细的日志，比方说你要记录谁操作了订单的状态，此扩展是无法做到的，你只能记录谁操作了订单，也只能记录订单的最新状态，操作之前的状态无法记录。
- 有特殊情况的话，可以使用 `yiier\humansLog\models\HLog::saveLog()` 方法单独记录日志。
- 模板使用说明可以看截图，也可以看 `src\views\h-log-template\_form.php` 文件。

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

[](#installation)

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

Either run

```
php composer.phar require --prefer-dist yiier/yii2-humans-log "*"

```

or add

```
"yiier/yii2-humans-log": "*"

```

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

Migrations
----------

[](#migrations)

Run the following command

```
php yii migrate --migrationPath=@yiier/humansLog/migrations/

```

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

[](#configuration)

Once the extension is installed, simply modify your application configuration as follows:

```
return [
    'modules' => [
        'humans-log' => [
            'class' => 'yiier\humansLog\Module',
            // 'mainLayout' => '@app/views/layout/hlog.php',
            // 'safeDelete' => false
        ],
    ],
];
```

Usage
-----

[](#usage)

### Method One (方式一，推荐)

[](#method-one-方式一推荐)

you need to include it in config in bootstrap section:

```
return [
    'bootstrap' => [
        'yiier\humansLog\EventBootstrap',
    ],
];
```

### Method Two (方式二)

[](#method-two-方式二)

Configure Controller class as follows :

```
use use yiier\humansLog\HLogBehavior;

class Controller extends \yii\web\Controller
{
    public function behaviors()
    {
        return [
            HLogBehavior::className(),
        ];
    }
}
```

Configure Model class as follows :

```
use use yiier\humansLog\HLogBehavior;

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

### DIY USE

[](#diy-use)

Demo

template

```
INSERT INTO `h_log_template` (`id`, `title`, `unique_id`, `template`, `method`, `status`, `created_at`, `updated_at`)
VALUES
	(16, '订单备注记录', 'orderRemarkUpdateRecord', '订单 {order_number} 的备注从『{old-remark}』更新为 『{remark}』', 5, 1, 1561953330, 1561953330);
```

```
public function afterSave($insert, $changedAttributes)
{
    parent::afterSave($insert, $changedAttributes);
    if (!\Yii::$app instanceof \yii\console\Application) {
        $changedRemark = ArrayHelper::getValue($changedAttributes, 'remark');
        if (!$insert && $this->remark != $changedRemark) {
            $logData = [
                'order_number' => $this->order_number,
                'old-remark' => $changedRemark,
                'remark' => $this->remark
            ];
            HLog::saveLog('orderRemarkUpdateRecord', $logData, $this->order_number);
        }
    }
}
```

### Routing

[](#routing)

You can then access Merit Module through the following URL:

```
http://localhost/path/to/index.php?r=humans-log/h-log
http://localhost/path/to/index.php?r=humans-log/h-log-template
http://localhost/path/to/index.php?r=humans-log/h-log-template/create

```

Screenshots
-----------

[](#screenshots)

[![Create log Template](https://camo.githubusercontent.com/02114205a2e1523b5c0b29a804bb70020b04756339a80bbe271bdba27ff6615e/68747470733a2f2f626c6f672d313235313233373430342e636f732e61702d6775616e677a686f752e6d7971636c6f75642e636f6d2f32303139303432383132303832332e706e67)](https://camo.githubusercontent.com/02114205a2e1523b5c0b29a804bb70020b04756339a80bbe271bdba27ff6615e/68747470733a2f2f626c6f672d313235313233373430342e636f732e61702d6775616e677a686f752e6d7971636c6f75642e636f6d2f32303139303432383132303832332e706e67)

[![Log Template](https://camo.githubusercontent.com/9a57645d06f9903925d5c7027168cfcc3dc3d897d12472b1b853e4768c2fff34/68747470733a2f2f626c6f672d313235313233373430342e636f732e61702d6775616e677a686f752e6d7971636c6f75642e636f6d2f32303139303432383132303733312e706e67)](https://camo.githubusercontent.com/9a57645d06f9903925d5c7027168cfcc3dc3d897d12472b1b853e4768c2fff34/68747470733a2f2f626c6f672d313235313233373430342e636f732e61702d6775616e677a686f752e6d7971636c6f75642e636f6d2f32303139303432383132303733312e706e67)

[![Logs](https://camo.githubusercontent.com/752ce7d1c4197805e09c656beb96a9d34c3e3f231fd7a41fac2444641960a511/68747470733a2f2f626c6f672d313235313233373430342e636f732e61702d6775616e677a686f752e6d7971636c6f75642e636f6d2f32303139303432383132303632362e706e67)](https://camo.githubusercontent.com/752ce7d1c4197805e09c656beb96a9d34c3e3f231fd7a41fac2444641960a511/68747470733a2f2f626c6f672d313235313233373430342e636f732e61702d6775616e677a686f752e6d7971636c6f75642e636f6d2f32303139303432383132303632362e706e67)

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity70

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

Recently: every ~40 days

Total

11

Last Release

2280d ago

Major Versions

v0.2 → v1.02019-04-27

### Community

Maintainers

![](https://www.gravatar.com/avatar/4c0612f70d09feb06ab5d24a31e0cc551f1ee547b42308c695e34d76181f18cf?d=identicon)[forecho](/maintainers/forecho)

---

Top Contributors

[![forecho](https://avatars.githubusercontent.com/u/1725326?v=4)](https://github.com/forecho "forecho (16 commits)")

---

Tags

logyii2-extensionlogyii2extension

### Embed Badge

![Health badge](/badges/yiier-yii2-humans-log/health.svg)

```
[![Health](https://phpackages.com/badges/yiier-yii2-humans-log/health.svg)](https://phpackages.com/packages/yiier-yii2-humans-log)
```

###  Alternatives

[lav45/yii2-activity-logger

Tools to store user activity log for Yii2

3456.3k](/packages/lav45-yii2-activity-logger)[kriss/yii2-log-reader

Yii2 log reader

1340.1k1](/packages/kriss-yii2-log-reader)

PHPackages © 2026

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