Download the PHP package youssefmansour9/audit-trail-package without Composer

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

Audit Trail Package

PHP CI PHPStan

A production-grade Composer package for tracking entity changes with complete audit history. Built with Clean Architecture, CQRS, Repository Pattern, and Dependency Injection.


Features


Requirements


Installation


Quick Start


Architecture

Clean Architecture layers

Layer Folder Responsibility
Domain src/Domain/ Business value objects, enums, exceptions. Zero dependencies.
Port src/Port/ Interface contracts (Repository, Logger). Inverts dependencies.
Application src/Application/ Use-case orchestration, validation rules. Depends only on Ports.
Infrastructure src/Infrastructure/ Concrete implementations (PDO). Swappable.
Facade src/AuditTrail.php Single entry point. DI-friendly.

Design patterns

Pattern Where Purpose
Clean Architecture Entire structure Separation of concerns, testability, swappability
CQRS AuditRepository Command methods (append) separated from Query methods (findBy*)
Repository AuditRepository + PDOAuditRepository Abstracts storage behind a collection-like interface
Dependency Injection Every class Dependencies provided via constructor, never created internally
Value Object AuditEntry Immutable, self-validating, equality by data
Facade AuditTrail Simplified public API hiding internal complexity
Static Factory AuditEntry::record(), AuditEntry::fromArray() Named constructors for different creation contexts
Primary Constructor AuditEntry Private constructor + public named constructors
Adapter PDOAuditRepository Adapts PDO to the Repository interface
Null Object NullLogger Default no-op logger when none provided

Usage

Recording changes

Batch recording (atomic)

All entries are validated before any are persisted. If the second entry fails validation, no entries are written.

Querying history

With Monolog


Database Schema

The schema file is located at src/Infrastructure/Persistence/Schema/mysql.sql.

Column guide

Column Type Purpose
id UUID v4 Unique identifier for the audit entry
aggregate_type string Entity type (e.g., "order", "user", "product")
aggregate_id string Entity identifier (e.g., "42", "uuid-value")
action enum string One of: CREATE, UPDATE, DELETE
old_state JSON or null The entity state before this change
new_state JSON or null The entity state after this change
performed_by string Who performed the action
performed_at datetime(6) Microsecond-precision timestamp
metadata JSON or null Extra context (IP, request ID, tags)

Testing

Tests use SQLite in-memory — no database server required. The test suite runs on CI with zero external dependencies.

Test structure

Test suite Tests What it covers
Domain\ActionTest 6 Enum values, cases, from/tryFrom
Domain\AuditEntryTest 20 Creation, serialization, reconstruction, validation
Domain\Exception\ExceptionTest 5 Exception hierarchy and messages
Application\AuditServiceTest 17 Use cases, validation rules, batch atomicity
Infrastructure\PDOAuditRepositoryTest 17 Full CRUD with SQLite, ordering, pagination, batch rollback
AuditTrailTest 8 Public facade delegation, createWithPdo factory

PHPStan

This project enforces level 9 (the maximum — property type hints, return type hints, generic array annotations, mixed type warnings, and strict comparison rules):


Contributing

See CONTRIBUTING.md.


License

MIT — see LICENSE.

Copyright (c) 2026 Youssef Mansour


All versions of audit-trail-package with dependencies

PHP Build Version
Package Version
Requires php Version >=8.3
ext-json Version *
ext-pdo Version *
psr/log Version ^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 youssefmansour9/audit-trail-package contains the following files

Loading the files please wait ...