Overview

AuditTrailBundle 4.x

AuditTrailBundle records Doctrine ORM entity changes and stores audit logs. It captures changes during flush and sends audits after postFlush by default, so normal writes stay fast while the audit path remains explicit and configurable.

current: 4.x PHP 8.4+ Symfony 7.4+ or 8.0+ Doctrine ORM 3.6+

When To Use It

Use AuditTrailBundle when a Symfony application needs reliable history for Doctrine entities, admin accountability, access auditing, compliance review, transport delivery, or recovery from accidental writes.

Entity History

Record create, update, delete, soft delete, collection changes, request metadata, and user context for audited Doctrine entities.

Transport Choice

Persist locally, dispatch through Messenger, send HTTP payloads, or combine paths with fallback behavior.

Admin Review

Use EasyAdmin and Symfony profiler integration to inspect logs without only querying raw database rows.

Integrity

Mask sensitive values, sign audit logs, verify stored signatures, and sign transport payloads.

Split-Phase Model

The bundle separates detection from delivery. That matters because Doctrine lifecycle work has strict rules about when entities and changesets are safe to inspect or persist.

Application       Doctrine ORM       AuditTrailBundle       Queue / Storage
     |                  |                    |                     |
     | flush()          |                    |                     |
     |----------------->|                    |                     |
     |                  | onFlush            |                     |
     |                  |------------------->| Compute diffs       |
     |                  |                    | Persist ORM-safe    |
     |                  |                    | audit rows when     |
     |                  |                    | allowed in-UoW      |
     |                  |<-------------------|                     |
     |                  | Execute SQL        |                     |
     |                  | postFlush          |                     |
     |                  |------------------->| Dispatch audit      |
     |                  |                    | Persist deferred    |
     |                  |                    | database audits     |
     | flush() returns  |                    |-------------------->|
     |<-----------------|                    | Async save
  • onFlush inspects entity and collection changes.
  • postFlush finalizes deferred work and dispatches supported transports.
  • Deferred database writes use a dedicated writer instead of re-entering Doctrine flush().

First Install

composer require rcsofttech/audit-trail-bundle

Continue with the Quick Start for schema migration, optional transport packages, and a first entity example.