Yii 2.0: yii2-audit

Auditing component for Yii2

Yii2 Audit

Join Chat Latest Version Software License Build Status Coverage Status Quality Score Total Downloads Yii2 Framework

Yii2 Audit is a module that records and displays web/cli requests, database changes, php/js errors and associated data.


  • Tracks minimal data in the base entry:

    • user_id - User ID of the visitor (if any), based on Yii::$app->user->id.
    • ip - IP Address of the visitor.
    • request_method - The method used to generate the request, eg: CLI for console requests and GET, POST, DELETE, PUT, PATCH, OPTIONS or HEAD for web requests.
    • ajax - If the page was requested using ajax.
    • route - The controller and action of the request.
    • duration - How long the request took to serve.
    • memory_max - The peak memory usage during the request.
    • created - The datetime the entry was created.
  • Tracks additional data using configurable Panels. Each panel is optional, and you can even create your own.

    • RequestPanel - Tracks all incoming web and console request data:
    • URL Information including the route and params.
    • PHP SuperGlobals $_GET, $_POST, $_SERVER, $_FILES and $_COOKIES.
    • Headers from the Request and Response.
    • AssetPanel - Asset Bundles loaded for the request.
    • ConfigPanel - Yii and PHP configuration that was used for the request.
    • DbPanel - SQL queries.
    • ErrorPanel - Record all PHP exceptions and errors in the background. Once logged you can configure a cron task to email the errors to a developer so issues can be fixed before they are even reported by a user.
    • JavascriptPanel - Automatically log JavaScript errors. Errors and warning are logged automatically by including JSLoggingAsset asset bundle. The javascript component also provides methods to manually add logging entries.
    • LogPanel - Yii logs.
    • MailPanel - Emails that were sent during the request
    • ProfilingPanel - Application profiling information.
    • TrailPanel - Database changes that were made during the request using the AuditTrailBehavior.
    • ExtraDataPanel - Extra data that you want to store.
    • YourOwnPanel - Create your own panel to capture any data you want.
  • Installs as a simple module so it can be added without any hassle.

  • You can either track specific actions and nothing else or exclude specific routes from logging (wildcard supported).

  • View your data. The module contains a nice viewer that is automatically made available when you add it to your configuration. It has configurable permissions to limit access to this functionality by IPs, roles or users.


Getting started? Try the Installation Guide. You will find further information in the Documentation.

For changes since the last version see the Changelog.



Audit Dashboard

Entry View

Audit Entry View

Trail Panel

Trail Panel

Database Panel

Database Panel

Log Panel

Log Panel

Profiling Panel

Profiling Panel

Error Panel

Error Panel

Javascript Panel

Javascript Panel


Thanks to everyone who has contributed.


BSD-3 - Please refer to the license.

Total 11 comments

#19449 report it
copyme at 2015/07/10 03:29am

now with this version, when i add this section in my main.php

'modules' => [
'audit' => 'bedezign\yii2\audit\Audit',

i have a blank page and the db is empty...

#19383 report it
Blizz at 2015/06/12 12:57pm

I've just drafted a new release (0.1.6) that allows you to toggle compression off completely.

If you can live with bigger records (in the end, space is less of a limiting factor today), you can use that. Just configure the module with 'compressData' => false. The data fields will then just contain a serialized text instead of binary data.

Hope that helps.

#19379 report it
copyme at 2015/06/10 08:16am
binary field

i test with binary field in postgres but i have an error

Database Exception – yii\db\Exception

Error Info: Array ( [0] => 22P02 [1] => 7 [2] => ERROR: invalid input syntax for type bytea ) ↵ Caused by: PDOException

SQLSTATE[22P02]: Invalid text representation: 7 ERROR: invalid input syntax for type bytea

in /var/www/start/_protected/vendor/yiisoft/yii2/db/Command.php at line 825

#19378 report it
copyme at 2015/06/10 07:53am

yes BLOB, sorry.

problem not solved...f the database is not in Utf8 or if you use postgres, extension not run. they are no insertion in the database.

#19371 report it
Blizz at 2015/06/05 11:19am

It's not a BLOG, it's a BLOB This simply means a binary field. If you get that set to the equivalent in Postgress (I must have a binary field) then all problems are probably solved. The extension stores binary data (gzipped) in the fields of type BLOB because otherwise your tables would get huge.

#19370 report it
copyme at 2015/06/05 09:45am
other problem

they are a lot of problem with postgres and charset. Not exist BLOG in postgres and if charset is not UTF8, they are no insertion in database

#19336 report it
copyme at 2015/05/24 12:35am
yii2 audit

ok, it is a problem with stability in the package


#19334 report it
Blizz at 2015/05/23 03:42am

Okay think I get it now. You probably have your composer marked for minimum-stability: stable right? I hadn't added a release yet so it wouldn't find that package in stable form. I just added a tag/release. You should be able to install it now.

#19333 report it
copyme at 2015/05/23 12:44am

no problem with dependency

Loading composer repositories with package information
Updating dependencies (including require-dev)
Adding VCS repository bower-asset/jquery
Adding VCS repository bower-asset/yii2-pjax
Reading bower.json of bower-asset/jquery (2.1.4)
Importing tag 2.1.4 (
Adding VCS repository bower-asset/punycode
Adding VCS repository bower-asset/jquery.inputmask
Reading bower.json of bower-asset/jquery.inputmask (3.1.63)
Importing tag 3.1.63 (
Reading bower.json of bower-asset/punycode (v1.3.2)
Importing tag v1.3.2 (
Reading bower.json of bower-asset/yii2-pjax (v2.0.4)
Importing tag v2.0.4 (
Adding VCS repository bower-asset/bootstrap
Adding VCS repository bower-asset/typeahead.js
Adding VCS repository bower-asset/jquery-ui
Reading bower.json of bower-asset/jquery-ui (1.11.4)
Importing tag 1.11.4 (
Reading bower.json of bower-asset/bootstrap (v3.3.4)
Importing tag v3.3.4 (
Reading bower.json of bower-asset/typeahead.js (v0.10.5)
Importing tag v0.10.5 (
Your requirements could not be resolved to an installable set of packages.

Problem 1 - The requested package bedezign/yii2-audit could not be found in any versio n, there may be a typo in the package name.

Potential causes: - A typo in the package name - The package is not available in a stable-enough version according to your min imum-stability setting see https://groups.google.com/d/topic/composer-dev/_g3ASeIFlrc/discussion f or more details.

Read https://getcomposer.org/doc/articles/troubleshooting.md for further commo n problems.

#19327 report it
Blizz at 2015/05/22 04:14am


Are you sure it was correctly added in the 'require'-section of your composer.json that it is effectively due to the audit package that the requirements fail? Try to run "composer -v update" to get you more info. Like this it is pretty hard to diagnose.

#19326 report it
copyme at 2015/05/22 04:08am


i try to use yii2-audit this extension (http://www.yiiframework.com/extension/yii2-audit/) but i have a problem. with other extension , i have no problem. my error :

Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

in my composer.json, i have added this in the require section by following the instruction : https://github.com/bedezign/yii2-audit

"bedezign/yii2-audit": "*"

i dont understand. could you help me ?

Leave a comment

Please to leave your comment.

Create extension
No downloadable files yet