Download the PHP package popphp/pop-audit without Composer

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

pop-audit

Build Status Coverage Status

Join the chat at https://discord.gg/TZjgT74U7E

Overview

Pop Audit is an auditing component of the Pop PHP Framework. It allows you to track and recall changes in model states, which is useful for rolling back mistakes or recovering lost data. It provides different adapters to achieve this, all of which are interchangeable using the same interface:

pop-audit is a component of the Pop PHP Framework.

Top

Install

Install pop-audit using Composer.

composer require popphp/pop-audit

Or, require it in your composer.json file

"require": {
    "popphp/pop-audit" : "^2.0.1"
}

Top

Quickstart

With the audit component, you can store model state data changes and recall them at a later date.

Storing Changes

To store the model data, there are two required data points - the model name and model ID. After that, optional data points such as user data or the domain can be stored. First we create the auditor and set the data points:

Then, we look at the changed model data. In this example, the model state contains 4 data points, 2 of which have changed: username and phone. Once passed to the auditor's send() method, it will "diff" the two states and record the differences, as well as snapshot of the final changed state:

Top

Retrieving Changes

Interacting with the auditor's adapter, the previously stored model states can be retrieved:

List all stored states

List stored states for a particular model and model ID

Other methods are available to help refine your search for previous states:

The state structure will look like:

The storing of the full state is on by default, can be turned off by passing a false boolean to the send() method:

Top

Diffing

In the above examples, the pop-audit component automatically handles "diffing" for you. If you have another resource that evaluates the differences, you can pass those directly into the auditor as well:

An example of this is the Pop\Db\Record class from the pop-db component. It automatically tracks the "dirty" values that have been changed while working with a record object. You can then used the getDirty() method of the Pop\Db\Record class to return an array with the keys old and new and pass them off to the auditor.

Top

Using Files

With the file adapter, you set the folder you want to save the audit record to, and save the model state changes like this:

In this case, the variable $logFile would contain the name of the audit log file, for example pop-audit-aed112d5d6de258762c03aa597a47f9b-653ec767ee591-1698613095.log in case it needs to be referenced again. That file will contain the JSON-encoded data that tracks the difference between the model states, as well as a snapshot of the full state (if provided):

Top

Using a Database

Using a database connection requires the use of the pop-db component and a database table class that extends the Pop\Db\Record class. Consider a database and table class set up in your application like this:

Then you can use the table adapter like this:

If needed, the variable $row contains the newly created record in the audit table.

Top

Using HTTP

You can also send your audit data to an HTTP service like this:

If needed, the variable $response contains the HTTP response returned by the HTTP request.

Top


All versions of pop-audit with dependencies

PHP Build Version
Package Version
Requires php Version >=8.2.0
popphp/popphp Version ^4.3.6
popphp/pop-db Version ^6.6.0
popphp/pop-http Version ^5.3.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 popphp/pop-audit contains the following files

Loading the files please wait ....