pvsaintpe/yii2-log

Package

Installs: 3 791

Dependents: 0

Suggesters: 0

Security: 0

Stars: 1

Watchers: 2

Forks: 1

Open Issues: 0

Type:yii2-extension

8.0.1 2019-06-08 10:22 UTC

README

Installation

The preferred way to install this extension is through composer.

Check the composer.json for this extension's requirements and dependencies. Read this web tip /wiki on setting the minimum-stability settings for your application's composer.json. Either run

$ php composer.phar require pvsaintpe/yii2-log "8.*"

or add

"pvsaintpe/yii2-log": "8.*"

to the require section of your composer.json file.

Additional information

All base models and query must be inherited from:

ActiveRecord extends \pvsaintpe\log\components\ActiveRecord ActiveQuery extends \pvsaintpe\log\components\ActiveQuery

To track changes, add to your model:

/**
 * @return bool
 */
public static function logEnabled()
{
    return true;
}

Build project

Every time when you change the database schema to be logged, run the command:

#!/usr/bin/env bash
php ./yii changelog/generate
php ./yii changelog/migrate --interactive=0

Customization

  1. To access the visual part, for example, to view revisions and change history of your data, add to the config:
// backend/configs/main.php
return [
    'modules' => [
        'changelog' => [
            'class' => 'pvsaintpe\log\Module',
        ],
    ]
];
  1. To fine-tune the logging system, use the configurator. For a complete list of available options, see pvsaintpe\log\components\Configs:
// common/configs/params.php
return [
    'changelog.configs' => [
        'db' => 'dbLog', // DB Storage for Log-tables
        'storageDb' => 'db', // DB Storage for Data-tables
        'adminTable' => 'admin', // Table Name for Admin's
        'tablePrefix' => '_log',
        'adminColumn => 'updated_by',
    ],
];

Usage

To activate all features of the component, use pvsaintpe\log\traits\SearchTrait in your Search-models. It is recommended to keep the log data in a separate database, although you are not limited in this.