auditor-doctrine-provider
Doctrine ORM provider for the auditor audit-log library
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
onFlushevent - 🔗 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:
- AuditingService — Hooks into Doctrine's
onFlushevent to detect entity changes - StorageService — Persists audit entries to the database via prepared statements
Data Flow
- Entity Change → Your application modifies a Doctrine entity and calls
flush() - Detection →
AuditingServicecatches theonFlushevent and collects entity changesets from the UnitOfWork - Processing →
TransactionProcessorcomputes diffs and prepares audit data - Event → A
LifecycleEventis dispatched with the audit payload and the entity object - Enrichment (optional) → Your listener(s) inspect the entity and populate
extra_data - Persistence →
StorageServicepersists the audit entry to the database
Supported Databases
| Database | Support 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
| Version | Status | Requirements |
|---|---|---|
| 1.x | Active development 🚀 | PHP >= 8.4, Doctrine DBAL >= 4.0, Doctrine ORM >= 3.2, auditor >= 4.0 |
Quick Links
Related Projects
- auditor — The core audit-log library
- auditor-bundle — Symfony bundle integrating DoctrineProvider
License
This library is released under the MIT License.