定制 rikcage/yii2-user-logs 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

rikcage/yii2-user-logs

最新稳定版本:0.0.2

Composer 安装命令:

composer require rikcage/yii2-user-logs

包简介

User logs actions YII2

README 文档

README

full and comfortable logs of user actions (visited pages), insert, update, delete

Installation

The preferred way to install this extension is through composer.

To install, either run

$ php composer.phar require rikcage/yii2-user-logs "*"

or add

"rikcage/yii2-user-logs": "*"

to the require section of your composer.json file.

Run migration to create logs table (it means that a connection to the database is already configured for the application)

./yii migrate --migrationPath=@rikcage/user-logs/migrations

Add the module

Include module to the config file (backend/config/main.php for advanced app or config/web.php and config/console for basic app)

	'modules' => [
    ...
		'logs' => [ // you can create several 'logs', 'logs_admin', etc. sections
                    // if you want another table different from '{{%logs}} or several tables
			'class' => 'rikcage\user_logs\UserLogs',
			'params' => [
				'userClass' => 'account\models\User',
				'username' => 'user_name',
				'userid' => 'user_id',
				//'log_table' => '{{%logs_admin}}', // if you want another table different from '{{%logs}}', default 'log_table' => '{{%logs}}'
			],
			'access_rules' => [ // Setting permissions for viewing logs (http://your_site/logs/logs)
				[
					'actions' => null, //for all
					'allow' => true,
					'roles' => ['@'],
				],
            ],
			//'behaviors_params' => [ // additional settings of the behaviors () method for Logic Controller,
                                    // eg using access control extensions.
			//	'as AccessBehavior' => [
			//		'class' => AccessBehavior::className(),
			//	],
			//],
			//'virtual_cron' => false, //default virtual_cron=true once a day deletes old logs for disable use virtual_cron=false
			//'var_name_last_delete' => 'logs_last_delete', // variable name the date of the last clean of the log, default var_name_last_delete=logs_last_delete
			'logs_live' => '-100 day', // lifetime of log
			'gitignore_list' => [ // ignored events of controllers and models.
				'rikcage\user_logs\controllers\LogsController',
			],

		],
	],

for disable use virtual_cron set 'virtual_cron' => false

Installation guide for the Controller

add to your Controller

use rikcage\user_logs\models\UserLog;

    ...

	public function beforeAction($action)
	{
		if (!parent::beforeAction($action)) {
			return false;
		}
		UserLog::initTable('logs'); // if you want another section with settings different from 'logs_admin' model
		$log = new UserLog;
		$log->actionlog('ACTION', $this);

		return true;
	}

Installation guide for the Model

add to your Model

use rikcage\user_logs\models\UserLog;

    ...

	public function behaviors()
	{
    ...
        //UserLog::initTable('logs_admin'); // if you want another section with settings different from 'logs' model
		return [
    ...
			UserLog::className(),
		];
	}

统计信息

  • 总下载量: 637
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 3
  • Watchers: 0
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-10-02