myzero1/yii2-log 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

myzero1/yii2-log

Composer 安装命令:

composer require myzero1/yii2-log

包简介

It can log by text,screenshot or both.

README 文档

README

The log module,include text log, screenshot log, and both.

Show time

Installation

The preferred way to install this module is through composer.

Either run

php composer.phar require myzero1/yii2-log:1.*

or add

"myzero1/yii2-log": "*"

to the require section of your composer.json file.

Setting

Once the extension is installed, simply modify your application configuration(main.php) as follows:

return [
    ......
    'bootstrap' => [
        ......
        'z1log',
        ......
    ],
    'modules' => [
        ......
        'z1log' => [
            'class' => '\myzero1\log\Module',    
            'params' => [
                'urlManager' => [
                    'rules' => [
                        // 'rate/area/index' => 'rate/jf-core-area/index',
                    ],
                ],
                'remarksFieldsKey' => [
                    'remark', // default filed
                    // 'r1', // custom field, can add it by yourself
                ],
                'userInfo' => [
                    'id' => function(){
                        if(\Yii::$app->user->isGuest){
                            $id = 0;
                        } else {
                            $id = \Yii::$app->user->identity->id;
                        }

                        return $id;
                    },
                    'name' => function(){
                        if(\Yii::$app->user->isGuest){
                            $name = 'system';
                        } else {
                            $name = \Yii::$app->user->identity->username;
                        }
                        
                        return $name;
                    }
                ],
                'template' => [
                    'user2/create' => [
                        'model' => 'all', // text,screenshot,all
                        'addToTable' => 'user', // for creating
                        'text' => function(){
                            return '添加用户'; 
                        },
                        'screenshot' => 'user2/update', // The template of screenshot
                        'obj' => [
                            'label' => '.field-user2-username .control-label',
                            'value' => '#user2-username',
                        ],
                        'remarks' => [// the items must be Closure
                            'remark' => function(){
                                return sprintf('Create it at %s.', date('Y-m-d H:i:s'));
                            },
                            // 'r1' => function(){return 'r1'.time();},
                        ],
                    ],
                    'user2/update' => [
                        'model' => 'all', // text,screenshot,all
                        'text' => function(){
                            return '修改用户'; 
                        },
                        'screenshot' => 'user2/update', // The template of screenshot
                        'obj' => [
                            'label' => '.field-user2-username .control-label',
                            'value' => '#user2-username',
                        ],
                        'remarks' => [// the items must be Closure
                            'remark' => function(){
                                return sprintf('Update it at %s.', date('Y-m-d H:i:s'));
                            },
                        ],
                    ],
                    'user2/delete' => [
                        'model' => 'all', // text,screenshot,all
                        'text' => function(){
                            return '删除用户'; 
                        },
                        'screenshot' => 'user2/update', // The template of screenshot
                        'obj' => [
                            'label' => '.field-user2-username .control-label',
                            'value' => '#user2-username',
                        ],
                        'remarks' => [// the items must be Closure
                            'remark' => function(){
                                return sprintf('Delete it at %s.', date('Y-m-d H:i:s'));
                            },
                        ],
                    ],
                ],
            ],
        ],
        ......
    ],
    ......
];

Apply migrations:

    php yii migrate --migrationPath=@vendor/myzero1/yii2-log/src/migrations

Usage

You can access Demo through the following URL:

http://localhost/path/to/index.php?r=z1log/z1log-log/index

or if you have enabled pretty URLs, you may use the following URL:

http://localhost/path/to/index.php/z1log/z1log-log/index

use z1logAdd($model, $screenshot, $screenshotParams, $text, $obj, $remarks) anywhere

\myzero1\log\components\export\Export::z1logAdd('all', 'user2/update', ['id'=>$model->id], 'create user', sprintf('username:%s', $model->username), ['remark'=>'this is a remark']);

Usage scenario

  • Just add config to mian.php,when we want to add log,there is updating with the action.· The screenshots will record the data before updating.

  • Use z1logAdd api,when we are create a new record.we get he id of the new record at action,so easy .

    /**
     * Creates a new User2 model.
     * If creation is successful, the browser will be redirected to the 'view' page.
     * @return mixed
     */
    public function actionCreate()
    {
        $model = new User2();

        if ($model->load(Yii::$app->request->post()) && $model->save()) {
            
            \myzero1\log\components\export\Export::z1logAdd('all', 'user2/update', ['id'=>$model->id], 'create user', sprintf('username:%s', $model->username), '');

            Yii::$app->getSession()->setFlash('success', '添加成功');
            return \myzero1\adminlteiframe\helpers\Tool::redirectParent(['index']);
        } else {
            return $this->render('create', [
                'model' => $model,
            ]);
        }
    }
  • Use z1logAdd api,when we want to add log,but there is not updating with the action.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2018-08-30

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固