bedezign/yii2-audit Yii2 Audit records and displays web/cli requests, database changes, php/js errors and associated data.

loggingaudittrail

Yii2 Audit

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

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

New stewardship from March 2024 on

We (@schmunk42, @eluhr) have taken stewardship of this project. Thank you @Blizzke for adding us to the GitHub maintainer list. Since we are still using this extension extensively, we are focussing on backward-compatibility and improvements.

Upgrading

yii2-audit 1.2.x

Existing projects with non-namespace migrations need to include @bedezign/yii2/audit/migrations/1.1.x in `migrationPath and skip namespaced migrations. (Issue #271)

PHP7.2 & Yii 2.0.13 or later

From PHP 7.2 on Object became a reserved keyword. Since enough time went by, we decided to assume everyone is on 7.2 and Yii 2.0.13 by now we won't be keeping 1.0.*-branch (pre PHP 7.2) up to date anymore.

Please use version 1.1.* or later.

Features

Powerful, yet Simple

  • 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.

Minimal Footprint

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.

Log 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. more info
  • 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. more info
  • LogPanel - Yii logs.
  • MailPanel - Emails that were sent during the request. more info
  • ProfilingPanel - Application profiling information.
  • TrailPanel - Database changes that were made during the request using the AuditTrailBehavior. more info
  • ExtraDataPanel - Extra data that you want to store. more info
  • CurlPanel - Track your applications cURL requests (including replies, log and headers) more info
  • YourOwnPanel - Create your own panel to capture any data you want. more info

Documentation

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

For changes since the last version see the Changelog.

Screenshots

Dashboard

Dashboard

Entry View

Audit Entry View

More Screenshots

More images are available from the Screenshots page.

Contributing

Contributions are welcome. Please refer to the contributing guidelines.

Thanks to everyone who has contributed.

Project Resources

License

BSD-3 - Please refer to the license. Analytics

Changelog

Changelog

1.2.7

  • Move differences in audit trail view in DetailWidget
  • New module option $enablePrettyDiffForTrails to prettyfied json output

1.2.6

  • Show diff in trails
  • Simplify structure for attributes in audit entry view
  • Fixed wrong request url in entry view

1.2.5

  • Add user ip callback

1.2.4

  • re-added namespaced migrations to maintain BC

1.2.3

  • improved memory usage

1.2.2

  • using db count because count reads objects into memory and result in an memory overflow
  • Fixed deprecated explode() null passing for parameter

1.2.1

  • Select only columns used in model in search models

1.2.0

  • Filter created date in db
  • Allow case insensitive filtering
  • remove message dropdown filter
  • Remove namespaces from migrations to support path migrations again
  • empty instread of strlen to support integer and string
  • Updated for mail-renderer and migrations with namespaces
  • Allow non integer user ids
  • Enh #232: Added exportAtIntervals log-target configuration to allow export during the request.

1.1.2 November 1, 2019

So finally a release. It's long overdue, I know. Trust me, there are reasons for my absence, but I'll skip the excuses part and promise to try to do better from now on, even though it's impossible to give any guarantee. There's tons more to do (like getting tests to work again etc), I wanted to get a new release out there first so everyone can go back to a stable version.

This module is now PHP 7.2 and Yii 2 2.0.13+ only.

  • Bug #270: Make panels compatible with yii2-debug 2.1.6 and later
  • Enh #267: Use Yii2's namespaced migrations functionality
  • Bug #263: fix bs4 issues from yii2-debug
  • Bug #261: Fix "group by" exception on SQL Server
  • Bug #246: fix when args missing from error trace
  • Enh #264: show the whole request url in entry view
  • Enh #259: French translation
  • Enh #252: Allow manual entry definition via setEntry function
  • Enh #251: Override Module::getInstance() to allow for derived Audit module classes
  • Enh #250: Added 'renderEmail' panel function detection to allow for custom email renderers (should still be tested, sorry, no data atm)

1.1.1 February 4, 2018

  • Enh #225: German translation
  • Enh #236: Chinese translation
  • Bug #221: Verify component existence in the console, terminate execution with more flair if not.

1.1.0 January 20, 2018

  • Enh #231: This release is identical to 1.0.13 except that it requires Yii 2.0.13 to make it compatible with PHP 7.2. It will still work on older PHP versions.

1.0.13 January 20, 2018

  • Bug #216: Migration failed for MSSQL on alter_audit_mail
  • Enh #219: Refactored chart panels
  • Enh: Use HTTP_X_FORWARDED_FOR as IP when it is set
  • Enh #217, #218: Optimized database queries for panels
  • Enh: Made php-mime-mail-parser optional (mail panel will now work without, with less functionality). This means you don't need the mailparse extension anymore to install Audit.
  • Bug #233: Made DbPanel work with versions that have the duplicate queries count
  • A new version will be released shortly (1.1.0) that will be PHP >= 7.2 and Yii >= 2.0.13. As of PHP 7.2 object is reserved as a type hint keyword and thus the Yii Object class was renamed to BaseObject. For PHP < 7.2 a workaround was added that still provides an Object class. This means that Audit v1.0 will work for Yii >= 2.0.13, as long as you do not use PHP >= 7.2

1.0.12 August 27, 2017

  • Enh #188: Ignore attributes when they contain arrays
  • Enh #191: add an option to disable most common timestamp fields
  • Bug #204: Fixed typo in Turkisch translations
  • Enh: Now using PhpMimeMailParser to display the email HTML
  • Enh: Improved IP detection for users behind a proxy
  • Enh #214: Reduced amount of queries to display the main screen

1.0.11 April 15, 2017

  • Bug: use correct database when running migrations if the database component is not "db"
  • Bug: check if the module has been installed (prevents errors prior to migration while installing)

1.0.10 March 26, 2017

  • Bug #201: Fix migration on pgsql

1.0.9 March 25, 2017

  • Enh #200: fix ID column name duplicating
  • Bug #199: Fix user id filtering
  • Enh #195: cleanup solo AuditEntry records
  • Enh #194: add ignoreKeys to RequestPanel to lower data usage
  • Enh #193: charts in panels shows "undefined"
  • Enh #189: enhance MailPanel
  • Bug #187: audit_mail table data too long
  • Enh #185: log config
  • Enh #182: Added ability to save overrided field with another name
  • Bug #184: Use full url for js log action
  • Bug #180: Fix dbPanel errors
  • Enh #174: Ability to use custom user id instead Yii::$app->user->id

1.0.8 November 11, 2016

  • Bug #172: Declaration of getUrl() compatible with yii\debug\Panel::getUrl()
  • Enh #171: Override to save related record label instead of id in AuditTrail
  • Bug #168: On certain errors the ProfilePanel data is not saved
  • Enh #167: Get parent model for audit trail

1.0.7 July 27, 2016

  • Bug #162: fix charts
  • Bug #160: error when config is setup but tables are not present
  • Bug #145: Bootstrap Array to String conversion fix
  • Bug #153: save user_id on finalize function

1.0.6 March 21, 2016

  • Bug #141: PHP7: ErrorPanel should support Throwable
  • Enh #140: AuditTrailSearch.field should allow array
  • Enh #138: Allow * as prefix in route matching
  • Bug: LogPanels without messages should still work

1.0.5 October 28, 2015

  • Enh: Added generateTrace()-function to the Helper for external usage
  • Enh: ErrorPanel now avoids duplicate exception logging
  • Enh: Javascript logging sets the type to 'unknown' if none was specified
  • Couple minor things fixed (tablenames and comments, thanks Evgeniy and Tobias)

1.0.4 August 11, 2015

  • Enh #114: Cleanup command should show counts
  • Bug #115: heroku trail page not working
  • Bug #116: js log/info not working
  • Enh #118: cleanup should use options instead of params
  • Bug #122: Migration tool throws SQL error in MySQL database with UTF8
  • POST data recognition improved
  • SOAP Panel now logs all exceptions during Soap Calls, not just SoapFaults

1.0.3 July 29, 2015

  • Bug #113: getting 404 on audit/js-log
  • Enh #112: generic cleanup() method in PanelTrait
  • Enh #103: Use error hash to determine different messages and files for error filter
  • Bug #99: IE8 support for the javascript logger
  • Enh #64: Support for SOAP
  • Bug #116: js log/info not working
  • Enh #114: Cleanup should show counts
  • Enh #110: All model saving data methods should be in the panels
  • Enh #118: Cleanup should use options instead of parameters
  • Enh #119: Heroku should showcase all panels

1.0.2 July 14, 2015

  • Enh #61: give each panel its own cleanup method
  • Enh #89: only show graphs and menu items for active panels
  • Enh #108: show IP address in entry grid
  • Bug #107: fix logging text or html on non-multipart messages
  • helper will always try to uncompress data
  • fixes for jslogging that were caused when pdo binary support was added
  • fix ordering in Version helper

1.0.1 July 12, 2015

  • Moved documentation to gh-pages branch
  • PostgreSQL compatibility
  • Added heroku demonstration page
  • Enh #100: cURL Panel now detects content types for POST and result. Supported: XML, JSON, query string

1.0.0 July 9, 2015

  • ability to undelete and roll back to any version of a model
  • added controllers and views for entry, trail, javascript and errors
  • added graphs to main page
  • created views that can be included in your application
  • audit_entry is created on demand for trails, javascript and errors
  • user callback to display custom output instead of user_id
  • extendable panel based logging
  • added extensive documentation
  • improved access control and added IP based access
  • no longer storing url data in entry table
  • created fresh migration scripts
  • added functionality to email errors via cron script
  • added unit test suite
  • huge code overhaul

0.1.0

  • initial release

Statistics

Downloads
GitHub Stars
GitHub Forks

Releases

Comments



1.2.6 is the latest of 32 releases



MIT license
Stats
194 github stars & 111 github forks
17 downloads in the last day
11043 downloads in the last 30 days
439056 total downloads