PHPackages                             imsamurai/audit-log - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Logging &amp; Monitoring](/categories/logging)
4. /
5. imsamurai/audit-log

ActiveCakephp-plugin[Logging &amp; Monitoring](/categories/logging)

imsamurai/audit-log
===================

CakePHP Audit Plugin

1.1.42(11y ago)2222[5 issues](https://github.com/imsamurai/CakePHP-Audit-Log-Plugin/issues)MITPHPPHP &gt;=5.3.0

Since Oct 27Pushed 11y ago4 watchersCompare

[ Source](https://github.com/imsamurai/CakePHP-Audit-Log-Plugin)[ Packagist](https://packagist.org/packages/imsamurai/audit-log)[ Docs](https://github.com/imsamurai/CakePHP-Audit-Log-Plugin)[ RSS](/packages/imsamurai-audit-log/feed)WikiDiscussions master Synced 4w ago

READMEChangelogDependencies (1)Versions (7)Used By (0)

API Documentation
-----------------

[](#api-documentation)

Check out [Audit log API Documentation](http://imsamurai.github.io/CakePHP-Audit-Log-Plugin/docs/master/)

Abstract
--------

[](#abstract)

[![Build Status](https://camo.githubusercontent.com/1cb82cde7695dc8080296dde6e28ea3951dd38082a7465b3faf59d678d90833e/68747470733a2f2f7472617669732d63692e6f72672f696d73616d757261692f43616b655048502d41756469742d4c6f672d506c7567696e2e706e67)](https://travis-ci.org/imsamurai/CakePHP-Audit-Log-Plugin) [![Coverage Status](https://camo.githubusercontent.com/07d957ccc04a6e7322ac1a9621ee82f8076c16546f81d30fcb9ffd95da6f06ef/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f696d73616d757261692f43616b655048502d41756469742d4c6f672d506c7567696e2f62616467652e706e673f6272616e63683d6d6173746572)](https://coveralls.io/r/imsamurai/CakePHP-Audit-Log-Plugin?branch=master) [![Latest Stable Version](https://camo.githubusercontent.com/edf872ef3c2139e44a058d6d31b904bc94ed7a415a8c150af2f9e7dbf221d727/68747470733a2f2f706f7365722e707567782e6f72672f696d73616d757261692f61756469742d6c6f672f762f737461626c652e706e67)](https://packagist.org/packages/imsamurai/audit-log) [![Total Downloads](https://camo.githubusercontent.com/063ae798b28abe0a26a5cf1fe86690c77f43fea69015e469c708466583cddd8a/68747470733a2f2f706f7365722e707567782e6f72672f696d73616d757261692f61756469742d6c6f672f646f776e6c6f6164732e706e67)](https://packagist.org/packages/imsamurai/audit-log) [![Latest Unstable Version](https://camo.githubusercontent.com/8b1f9d0954edf450aabb5f4e68ebb692a6fa9eeab5f3d0b27e4615668104539d/68747470733a2f2f706f7365722e707567782e6f72672f696d73616d757261692f61756469742d6c6f672f762f756e737461626c652e706e67)](https://packagist.org/packages/imsamurai/audit-log) [![License](https://camo.githubusercontent.com/9d038221b051ec759f9232703534f4fa37eecab445fccc9ed249ac0016a08de9/68747470733a2f2f706f7365722e707567782e6f72672f696d73616d757261692f61756469742d6c6f672f6c6963656e73652e706e67)](https://packagist.org/packages/imsamurai/audit-log)

A logging plugin for [CakePHP](http://cakephp.org). The included `AuditableBehavior` creates an audit history for each instance of a model to which it's attached.

The behavior tracks changes on two levels. It takes a snapshot of the fully hydrated object *after* a change is complete and it also records each individual change in the case of an update action.

Features
--------

[](#features)

- Support for CakePHP 2.0. Thanks, @jasonsnider.
- Tracks object snapshots as well as individual property changes.
- Allows each revision record to be attached to a source -- usually a user -- of responsibility for the change.
- Allows developers to ignore changes to specified properties. Properties named `created`, `updated` and `modified` are ignored by default, but these values can be overwritten.
- Handles changes to HABTM associations.
- Fully compatible with the [`PolymorphicBehavior`](http://bakery.cakephp.org/articles/view/polymorphic-behavior).
- Does not require or rely on the existence of explicit models revisions (`AuditLog`) and deltas (`AuditLogDeltas`).

Installation
------------

[](#installation)

### CakePHP &gt;= 2.0

[](#cakephp--20)

#### As an Archive

[](#as-an-archive)

1. Download and extract the source to `app/Plugin/AuditLog`.

#### As a Submodule

[](#as-a-submodule)

1. `$ git submodule add git://github.com/imsamurai/CakePHP-Audit-Log-Plugin.git /app/Plugin/AuditLog`
2. `$ git submodule init`
3. `$ git submodule update`

#### Via composer

[](#via-composer)

1. add into your composer "require": { "imsamurai/audit-log": "1.1.\*", }
2. `composer update`

To create tables you can use schema shell. To create tables execute:

```
cd /app/
chmod +x ./Console/cake
./Console/cake schema create -p AuditLog

```

### CakePHP 1.3.x

[](#cakephp-13x)

For use with CakePHP 1.3.x, be sure to use code from the `1.3` branch and follow the instructions in that README file (NOT MAINTAINED).

### Next Steps

[](#next-steps)

1. Run the `install.sql` file on your CakePHP application database or use schema. This will create the `audits` and `audit_deltas` tables that will store each object's relevant change history.
2. Add plugin into `bootstrap.php`

    ```
    CakePlugin::load('AuditLog', array('bootstrap' => true));
    ```
3. Create a `currentUser()` method, if desired.

    The `AuditableBehavior` optionally allows each changeset to be "owned" by a "source" -- typically the user responsible for the change. Since user and authentication models vary widely, the behavior supports a callback method that should return the value to be stored as the source of the change, if any.

    The `currentUser()` method must be available to every model that cares to track a source of changes, so I recommend that a copy of CakePHP's `app_model.php` file be created and the method added there. Keep it DRY, right?

    The behavior expects the `currentUser()` method to return an associative array with an `id` key. Continuing from the example above, the following code might appear in the `AppModel`:

    ```
    public function currentUser() {
      return AuthComponent::user();
    }
    ```
4. Attach the behavior to any desired model and configure.

Usage
-----

[](#usage)

### AuditableBehavior

[](#auditablebehavior)

Applying the `AuditableBehavior` to a model is essentially the same as applying any other CakePHP behavior. The behavior does offer a few configuration options:

 `ignore` An array of property names to be ignored when records are created in the deltas table. `habtm` An array of models that have a HABTM relationship with the acting model and whose changes should be monitored with the model. If the HABTM model is auditable in its own right, don't include it here. This option is for related models whose changes are \_only\_ tracked relative to the acting model.### AuditHelper

[](#audithelper)

- `user(user)` render user name with link to user profile (see config `AuditLog.User`)
- `listBlock(conditions, ajax)` render widget with compact table of audit logs depends on `conditions` and `ajax`. Second parameter means that widget will be loaded by ajax or request action (default is ajax). This method simply invoke action `AuditController::index` with `list=1` and `conditions` (also `count=` if it set).

### AuditController

[](#auditcontroller)

For filter by date you can use all formats (single or range) that constructor of `DateTime` can understand. For example:

- `2014/11/05 TO 2014/11/06` - will be range from 05.11.2014 00:00:00 to 06.11.2014 00:00:00
- `2014/11/05 01:02:20 TO 2014/11/06 15:02:21` - from 05.11.2014 01:02:20 to 06.11.2014 15:02:21
- `05.11.2014 01:02:20 to 06.11.2014 15:02:21` - from 05.11.2014 01:02:20 to 06.11.2014 15:02:21
- `2014/11/05` - from 05.11.2014 00:00:00 to 05.11.2014 23:59:59
- `2014/11/05 03:40:21` - date must be equals to 05.11.2014 03:40:21

Hint: you can use [bootstrap daterange picker](https://github.com/dangrossman/bootstrap-daterangepicker) for this field.

### Syntax

[](#syntax)

```
# Simple syntax accepting default options
class Task extends AppModel {
	public $actsAs = array( 'AuditLog.Auditable' );

	#
	# Additional model code.
	#
}

# Syntax with explicit options
class Task extends AppModel {
	public $actsAs = array(
		'AuditLog.Auditable' => array(
			'ignore' => array( 'active', 'name', 'updated' ),
			'habtm'  => array( 'Type', 'Project' )
		)
	);

	#
	# Additional model code.
	#
}
```

Limitations
-----------

[](#limitations)

- The master branch is not backwards compatible with CakePHP &lt;=1.3.x. If you need compatibility with these version please install the code from the `1.3` branch and follow the instructions in that README.

License
-------

[](#license)

This code is licensed under the [MIT license](http://www.opensource.org/licenses/mit-license.php).

Notes
-----

[](#notes)

Feel free to submit bug reports or suggest improvements in a ticket or fork this project and improve upon it yourself. Contributions welcome.

Changelog
---------

[](#changelog)

### 1.1.1

[](#111)

- Add link `view all` in widget

### 1.1.0

[](#110)

- Add to composer and travis.
- Change source\_id to user\_id field in db.
- Handle case of saving AuditDelta for array value in field (actual saving for model is provided by )
- Default view for list of audit records with pagination and filter (for nice style you need bootstrap 2)
- Default view for concrete audit record and it deltas
- Helper that has ajax/requestAction widget for display short list of audit records and format user email with link to user view in your application
- Some additional parameters you can see in plugin bootstrap.php

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance0

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community18

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 53.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~20 days

Total

6

Last Release

4109d ago

Major Versions

1.1.41 → 114.x-dev2015-01-27

### Community

Maintainers

![](https://www.gravatar.com/avatar/ab9b1bb43e8563f1ff3fd78cb0bf0b28b55026a9f792f2b26aefae882e1512d2?d=identicon)[imsamurai](/maintainers/imsamurai)

---

Top Contributors

[![robwilkerson](https://avatars.githubusercontent.com/u/7735?v=4)](https://github.com/robwilkerson "robwilkerson (36 commits)")[![jasonsnider](https://avatars.githubusercontent.com/u/209596?v=4)](https://github.com/jasonsnider "jasonsnider (14 commits)")[![imsamurai](https://avatars.githubusercontent.com/u/843002?v=4)](https://github.com/imsamurai "imsamurai (8 commits)")[![wuilliam321](https://avatars.githubusercontent.com/u/236566?v=4)](https://github.com/wuilliam321 "wuilliam321 (4 commits)")[![saji89](https://avatars.githubusercontent.com/u/236861?v=4)](https://github.com/saji89 "saji89 (1 commits)")[![ptica](https://avatars.githubusercontent.com/u/169873?v=4)](https://github.com/ptica "ptica (1 commits)")[![paulleephp](https://avatars.githubusercontent.com/u/2199146?v=4)](https://github.com/paulleephp "paulleephp (1 commits)")[![CpuID](https://avatars.githubusercontent.com/u/916201?v=4)](https://github.com/CpuID "CpuID (1 commits)")[![rchavik](https://avatars.githubusercontent.com/u/39490?v=4)](https://github.com/rchavik "rchavik (1 commits)")

---

Tags

logplugincakephpAudit

### Embed Badge

![Health badge](/badges/imsamurai-audit-log/health.svg)

```
[![Health](https://phpackages.com/badges/imsamurai-audit-log/health.svg)](https://phpackages.com/packages/imsamurai-audit-log)
```

###  Alternatives

[robwilkerson/cakephp-audit-log-plugin

Audit Plugin for CakePHP

10167.8k](/packages/robwilkerson-cakephp-audit-log-plugin)[jadb/cakephp-monolog

CakePHP Monolog Plugin

5518.9k](/packages/jadb-cakephp-monolog)[putyourlightson/craft-log-to-file

Logs messages to a specific log file for Craft CMS.

29368.0k5](/packages/putyourlightson-craft-log-to-file)[sandreu/cake-sentry

Sentry error handler plugin for CakePHP2

1640.2k](/packages/sandreu-cake-sentry)[lordsimal/cakephp-sentry

Sentry plugin for CakePHP

12270.3k](/packages/lordsimal-cakephp-sentry)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
