Download the PHP package nineinchnick/yii2-audit without Composer

On this page you can find all versions of the php package nineinchnick/yii2-audit. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package yii2-audit

yii2-audit

Extensions to the Yii 2 PHP framework allowing tracking and viewing change history of a model.

Changes are tracked using triggers, but model events should also be available as a fallback when using an unsupported database.

Provides:

Installation

Install via composer:

composer require nineinchnick/yii2-audit

Warning! If the database is restored from a dump, it's necessary to reenumaret table oids in audits.logged_actions.relation_id column using the following query:

UPDATE audits.logged_actions SET relation_id = (schema_name || '.' || table_name)::regclass::oid;

Recording changes

Attach the behavior to the model, after the Blameable and Timestamp behaviors:

use yii\behaviors\BlameableBehavior;
use yii\behaviors\TimestampBehavior;
use nineinchnick\audit\behaviors\TrackableBehavior;

public function behaviors()
{
    return [
        BlameableBehavior::className(),
        TimestampBehavior::className(),
        [
            'class' => TrackableBehavior::className(),
            'mode' => TrackableBehavior::MODE_TRIGGER,
        ],
    ];
}

If using trigger mode, run a command that generates migrations, which would create or update database objects like triggers and audit tables.

First, configure the controller in your console config:

    'controllerMap' => [
        'audit' => [
            'class' => 'nineinchnick\audit\console\AuditController',
        ],
    ],
    // .... rest of configuration

Then run the command:

./yii audit/migration --modelName=AR_MODEL_CLASS

where AR_MODEL_CLASS is your model class name.

Displaying changes

To view the change history, use the provided module in your app config:

    'modules' => [
        'audit' => [
            'class' => 'nineinchnick\audit\Module',
        ],
        // .... other modules
    ],

Sample configuration

'audit'      => [
    'class'   => 'nineinchnick\audit\Module',
    'tables'  => [
        'orders' => [
            'model'         => 'netis\orders\models\Order',
            'hiddenColumns' => ['id', 'created_on', 'author_id'],
            'updateSkip'    => ['updated_on', 'editor_id'],
            'relations'     => [
                'editor' => [
                    'type'                 => 'LEFT JOIN',
                    'table'                => '{{%users}}',
                    'on'                   => 'editor_id = u.id',
                    'alias'                => 'u',
                    'representive_columns' => 'username',
                    'label'                => Yii::t('models', 'Editor'),
                ],
            ]
        ],
    ],
    'filters' => [
        'dateFrom' => [
            'format'      => 'date',
            'attribute'   => 'operation_date',
            'widgetClass' => 'omnilight\widgets\DatePicker',
            'options'     => ['class' => 'form-control'],
            'dateFormat'  => 'yyyy-MM-dd',
            'rules'       => [
                [
                    'validator' => 'date',
                    'options'   => ['format' => 'Y-m-d'],
                ]
            ],
            'criteria'    => [
                'operator' => '>=',
            ],
        ],
        'dateTo'   => [
            'format'      => 'date',
            'attribute'   => 'operation_date',
            'widgetClass' => 'omnilight\widgets\DatePicker',
            'options'     => ['class' => 'form-control'],
            'dateFormat'  => 'yyyy-MM-dd',
            'rules'       => [
                [
                    'validator' => 'date',
                    'options'   => ['format' => 'Y-m-d'],
                ]
            ],
            'criteria'    => [
                'operator' => '<=',
            ],
        ],
    ],
],

References


All versions of yii2-audit with dependencies

PHP Build Version
Package Version
Requires yiisoft/yii2 Version *
yiisoft/yii2-bootstrap Version *
hanneskod/classtools Version 1.0.*
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package nineinchnick/yii2-audit contains the following files

Loading the files please wait ....