Download the PHP package robwilkerson/cakephp-audit-log-plugin without Composer

On this page you can find all versions of the php package robwilkerson/cakephp-audit-log-plugin. 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 cakephp-audit-log-plugin

Audit Log Plugin

A logging plugin for CakePHP 2.x. 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

Versions

CakePHP 2.x

Use the current master branch and follow the instructions below.

CakePHP 3.x

The dev-3.x branch is now dedicated to any CakePHP 3.x development but is still WIP. If you are looking for working solutions you can look at the plugins listed at Awesome CakePHP

CakePHP 1.3.x

Use code from the 1.3 branch and follow the instructions in that README file. Please note that development has ended for this version.

Installation (2.x)

Installation Options

Using Composer

From your /app/ folder run:

This will automatically update your composer.json, download and install the required packages.

As an Archive

  1. Click the big ol' Downloads button next to the project description.
  2. Extract the archive to app/Plugin/AuditLog.

As a Submodule

  1. $ git submodule add git://github.com/robwilkerson/CakePHP-Audit-Log-Plugin.git <path_to>/app/Plugin/AuditLog
  2. $ git submodule init
  3. $ git submodule update

Load the Plugin

In app/Config/bootstrap.php add the following line:

`

Setup Database

To create the necessary tables, you can use the schema shell. Run from your /app/ folder:

php ./Console/cake.php schema create -p AuditLog

This will create the audits and audit_deltas tables that will store each object's relevant change history.

Next Steps

  1. 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 AppModel.php file be created and the method added there. Keep it DRY, right?

    Storing the changeset source can be a little tricky if the core Auth component is being used since user data isn't readily available at the model layer where behaviors lie. One option is to forward that data from the controller. One means of doing this is to include the following code in AppController::beforeFilter():

    `

    The behavior expects the currentUser() method to return an associative array with an id key. It is also possible to set a description key to add additional details about the user. Continuing from the example above, the following code might appear in the AppModel:

    `

  2. Attach the behavior to any desired model and configure it to your needs.

Configuration

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



### Callbacks

The plugin offers multiple [Callbacks](http://book.cakephp.org/2.0/en/models/callback-methods.html) that allow the execution of additional logic before or after an operation of this Plugin. 

To add a custom Callback create a method with one of the names listed below in your audited model.

#### afterAuditCreate
###### afterAuditCreate(Model $Model)

Triggers if a new record is inserted in the Audit table
* `$Model` Name of the model where the record is created

#### afterAuditUpdate
###### afterAuditCreate(Model $Model, array $original, array $updates, int $auditId)

Triggers if a record is updated in the Audit table.
* `$Model` Name of the model where record is updated
* `$original` Contains a copy of the object as it existed prior to the save
* `$updates` Set of records that have been updated
* `$auditId` Id of the record in the `Audit` table

#### afterAuditProperty
###### afterAuditCreate(Model $Model, string $propertyName, string $oldValue, string $newValue)

Triggers each time a property is inserted into the `audit_deltas` table.  
* `$Model` Name of the model where record is created / updated
* `$propertyName` Name of the property (field name)
* `$oldValue` Original value of the property
* `$newValue` New value of the property

## License

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

## Notes

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

All versions of cakephp-audit-log-plugin with dependencies

PHP Build Version
Package Version
Requires php Version >=5.3.0
composer/installers 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 robwilkerson/cakephp-audit-log-plugin contains the following files

Loading the files please wait ....