Download the PHP package ez-php/audit without Composer

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

ez-php/audit

Event-driven audit log module for ez-php. Records entity lifecycle changes (CREATE, UPDATE, DELETE) to a database table and exposes a fluent query API.

Installation

Register the service provider:

AuditServiceProvider requires DatabaseInterface and ez-php/events (EventServiceProvider) to be registered before it.

Database Schema

The module auto-creates the audit_logs table on first write (ensureTable()). For production use, prefer running a migration:

Usage

Dispatching audit events from repositories

Audit records are created by dispatching events from repository methods:

AuditServiceProvider registers AuditListener automatically — no manual listener registration needed.

Querying the audit trail

All filter methods return a clone — chaining does not modify the original query.

Programmatic logging (without events)

Design

Integration via events, not ORM core. Repositories dispatch EntityCreatedEvent, EntityUpdatedEvent, and EntityDeletedEvent. AuditListener (registered by the service provider) converts them to AuditRecord and writes to the database. No ORM kernel changes required.

AuditQuery is immutable. All filter methods (action(), since(), until(), byUser(), limit()) return a clone. Re-use the same base query safely.

ensureTable() for zero-config development. AuditLogger auto-creates audit_logs on first write, adapting DDL to the PDO driver (SQLite for tests, MySQL for production). Production deployments should prefer a migration.

No hard ORM dependency. Depends only on ez-php/contracts and ez-php/events. Works with any persistence mechanism that dispatches the provided event types.

API Reference

AuditAction (enum)

Case Value
AuditAction::CREATE 'create'
AuditAction::UPDATE 'update'
AuditAction::DELETE 'delete'

AuditRecord (value object)

Property Type Description
entityType string Class name or identifier
entityId string Primary key (cast to string)
action AuditAction What happened
oldValues array<string, mixed> Before-state (empty for creates)
newValues array<string, mixed> After-state (empty for deletes)
userId string\|null Who triggered the change
createdAt DateTimeImmutable When it happened

Static factories: AuditRecord::fromCreated(), ::fromUpdated(), ::fromDeleted().

AuditQuery (fluent query builder)

Method Description
AuditQuery::for(class, id) Scope to entity; returns new query
->action(AuditAction) Filter by action type
->since(DateTimeImmutable) Filter by minimum created_at
->until(DateTimeImmutable) Filter by maximum created_at
->byUser(int\|string) Filter by user_id
->limit(int) Limit result count
->get() Execute; return list<AuditRecord>
->first() Return latest record or null
->count() Return total count

Events

Class When to dispatch
EntityCreatedEvent Entity created
EntityUpdatedEvent Entity updated
EntityDeletedEvent Entity deleted

All versions of audit with dependencies

PHP Build Version
Package Version
Requires php Version ^8.5
ez-php/console Version ^2.0
ez-php/contracts Version ^2.0
ez-php/events Version ^2.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 ez-php/audit contains the following files

Loading the files please wait ...