Skip to main content
Version: 1.x

auditor-doctrine-provider

Doctrine ORM provider for the auditor audit-log library

Latest Stable Version License Total Downloads

What is auditor-doctrine-provider?

auditor-doctrine-provider is the Doctrine ORM provider for the auditor library. It brings automatic audit-logging to any application using Doctrine ORM, tracking inserts, updates, deletes, and many-to-many relationship changes on your entities.

Key Features

  • 📝 Automatic change tracking — Captures inserts, updates, and deletes automatically via Doctrine's onFlush event
  • 🔗 Relationship tracking — Records many-to-many associations and dissociations
  • 👤 User attribution — Records who made the changes and their IP address
  • 🔒 Transactional integrity — Audit entries are inserted within the same database transaction as the originating flush
  • 🎯 Flexible configuration — Choose which entities and fields to audit via PHP attributes or code
  • 🔐 Security controls — Define who can view audit logs
  • 🗄️ Multi-database support — Store audits in a separate database if needed

Architecture Overview

The provider is built on top of the auditor core architecture:

  1. AuditingService — Hooks into Doctrine's onFlush event to detect entity changes
  2. StorageService — Persists audit entries to the database via prepared statements

Data Flow

  1. Entity Change → Your application modifies a Doctrine entity and calls flush()
  2. DetectionAuditingService catches the onFlush event and collects entity changesets from the UnitOfWork
  3. ProcessingTransactionProcessor computes diffs and prepares audit data
  4. Event → A LifecycleEvent is dispatched with the audit payload and the entity object
  5. Enrichment (optional) → Your listener(s) inspect the entity and populate extra_data
  6. PersistenceStorageService persists the audit entry to the database

Supported Databases

DatabaseSupport Level
MySQL✅ Full
MariaDB✅ Full
PostgreSQL✅ Full
SQLite✅ Full

NOTE

The DoctrineProvider should work with any database supported by Doctrine DBAL, though only the above are actively tested.

Version Compatibility

VersionStatusRequirements
1.xActive development 🚀PHP >= 8.4, Doctrine DBAL >= 4.0, Doctrine ORM >= 3.2, auditor >= 4.0

License

This library is released under the MIT License.