Download the PHP package cornernote/yii2-audit without Composer

On this page you can find all versions of the php package cornernote/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

Join Chat Latest Version Build Status Coverage Status Quality Score Total Downloads

Yet another auditing module. This is based on a couple of other projects out there:

Features

Installs as a simple module so it can be added without too much hassle.

Installing

Example:

'bootstrap' => ['log', 'auditing', ...],
'controllerNamespace' => 'frontend\controllers',

'modules' => [
    'auditing' => [
        'class' => 'bedezign\yii2\audit\Auditing',
        'ignoreActions' => 'debug/*',
    ],
],

This installs the module with auto loading, instructing it to not log anything debug related.

Additional options

'modules' => [
    'auditing' => [
        'class' => 'bedezign\yii2\audit\Auditing',
        'db' => 'db', // Name of the component to use for database access
        'trackActions' => ['*'], // List of actions to track. '*' is allowed as the last character to use as wildcard
        'ignoreActions' => 'debug/*', // Actions to ignore. '*' is allowed as the last character to use as wildcard (eg 'debug/*')
        'truncateChance' => 75, // Chance in % that the truncate operation will run, false to not run at all
        'maxAge' => 'debug', // Maximum age (in days) of the audit entries before they are truncated
        'accessUsers' => [1, 2], // (List of) user(s) IDs with access to the viewer, null for everyone (if the role matches)
        'accessRoles' => ['admin'], // (List of) role(s) with access to the viewer, null for everyone (if the user matches)
    ],
],

Word of caution: The module is configured by default to only allow viewing access to users with the role 'admin'. This functionality is only available in Yii if you have enabled RBAC (via the authManager-component). If not, please set this option to null. If you do so you should consider activating the accessUsers-option, you don't want to give everyone access to your auditing data!

Error Logging

If you want errors to be logged, you have to register the included errorhandler as well in you configuration:

'errorHandler' => [
   'class' => '\bedezign\yii2\audit\components\web\ErrorHandler',
   'errorAction' => 'site/error',
],

Database changes

If you want database changes to be logged, you have to add the AuditingBehavior to the models you want to log.

public function behaviors()
{
    return [
        'bedezign\yii2\audit\AuditingBehavior'
    ];
}

Additional options

public function behaviors()
{
    return [
        'LoggableBehavior' => [
            'class' => 'sammaye\audittrail\LoggableBehavior',
            'allowed' => ['some_field'], // Array with fields to save. You don't need to configure both `allowed` and `ignored`
            'ignored' => ['another_field'], // Array with fields to ignore. You don't need to configure both `allowed` and `ignored`
            'ignoredClasses' => ['common\models\Model'], // Array with classes to ignore
            'skipNulls' => false, // Skip fields where bouth old and new values are NULL
            'active' => true // Is the behavior is active or not
        ]
    ];
}

Only log database changes

If you only want to log the database changes you should use the following module setting. All pageview logging will be ignored.

'modules' => [
    'auditing' => [
        'class' => 'bedezign\yii2\audit\Auditing',
        'ignoreActions' => ['*'],
    ],
],

There is a grid for only database changes available at:

http://localhost/path/to/index.php?r=auditing/default/trail

Render Audit Log for a Model

Model:

Controller:

View

Javascript Logging

The module also supports logging of javascript errors, warnings and even regular log entries. To activate, register the assets\JSLoggingAsset in any of your views:

 \bedezign\yii2\audit\assets\JSLoggingAsset::register($this);

This will activate the logger automatically. By default all warnings and errors are transmitted to the backend.

The default configuration assumes that the module was added as "auditing" (so the log url would be "/auditing/javascript/log"). If that is not the case, please make sure to update the setting somewhere in your javascript:

window.jsLogger.logUrl = '/mymodulename/javascript/log';

All javascript logging will be linked to the entry associated with the page entry created when you performed the initial request. This is accomplished by adding the ID of that entry in the window-object (window.auditEntry).

Beware: If you use ajax or related technologies to load data from the backend, these requests might generate their own auditing entries. If those cause backend errors they will be linked to that new entry. This might be a bit weird with the javascript logging being linked to the older entry.

Extra Data

It is possible to add extra custom data to the current audit entry by simply calling:

\bedezign\yii2\audit\Auditing::current()->data('name', 'extra data can be an integer, string, array, object or whatever', 'optional type');

Or if you prefer:

\Yii::$app->auditing->data(('name', 'extra data can be an integer, string, array, object or whatever', 'optional type');

Emailing Errors

A command is available to email errors which can be added to your cron.

You should ensure you have setup a mailer component and have a scriptUrl property in the urlManager component in your console configuration. For example:

Render AuditEntry.id in Layout

It is often useful for users to be able to report the AuditEntry.id to the developer. To render the ID to the page include the partial provided:

Viewing the audit data

Assuming you named the module "auditing" you can then access the auditing module through the following URL:

http://localhost/path/to/index.php?r=auditing

If you would like to see all database changes individually you can access:

http://localhost/path/to/index.php?r=auditing/default/trail

Screenshots


All versions of yii2-audit with dependencies

PHP Build Version
Package Version
Requires php Version >=5.4.0
yiisoft/yii2 Version 2.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 cornernote/yii2-audit contains the following files

Loading the files please wait ....