auditor
The missing audit log library for PHP
What is auditor?
auditor is a PHP library that provides an easy and standardized way to collect audit logs. It is designed to track changes made to your entities and persist them as audit trails.
Key Features
- 📝 Automatic change tracking — Captures inserts, updates, and deletes automatically
- 👤 User attribution — Records who made the changes and their IP address
- 🎯 Flexible configuration — Choose which entities and fields to audit
- 🔐 Security controls — Define who can view audit logs
- 🔌 Provider-based architecture — Storage and query layer are fully delegated to providers
Architecture Overview
The library is architected around two core concepts:
- Auditing Services — Responsible for collecting audit events when changes occur
- Storage Services — Responsible for persisting audit traces to the database
These services are implemented by Providers. Each provider handles a specific storage technology (Doctrine ORM, Eloquent, etc.).
Data Flow
- Entity Change → Your application modifies an entity via Doctrine
- Detection →
AuditingServicedetects the change through Doctrine events - Processing →
TransactionProcessorcomputes diffs and prepares audit data (withextra_data = null) - Event → A
LifecycleEventis dispatched with the audit payload and the entity object - Enrichment (optional) → Your listener(s) inspect the entity and populate
extra_datain the payload - Persistence →
StorageServicepersists the audit entry to the database
Available Providers
| Provider | Package | Storage technology |
|---|---|---|
| DoctrineProvider | auditor-doctrine-provider | Doctrine ORM / DBAL |
Need a different backend? See Building a Custom Provider.
Database Support
Database support depends on the provider used. Via DoctrineProvider:
| Database | Support Level |
|---|---|
| MySQL | ✅ Full |
| MariaDB | ✅ Full |
| PostgreSQL | ✅ Full |
| SQLite | ✅ Full |
NOTE
DoctrineProvider should work with any database supported by Doctrine DBAL, though only the above are actively tested.
Version Compatibility
| Version | Status | Requirements |
|---|---|---|
| 4.x | Active development 🚀 | PHP >= 8.4, Symfony >= 8.0 |
| 3.x | Active support | PHP >= 8.2, Symfony >= 5.4 |
| 2.x | End of Life | PHP >= 7.4, Symfony >= 4.4 |
| 1.x | End of Life | PHP >= 7.2, Symfony >= 3.4 |
Quick Links
- Installation Guide
- Quick Start
- Configuration Reference
- DoctrineProvider
- Building a Custom Provider
- Querying Audits
- Extra Data
- API Reference
Related Projects
- auditor-bundle - Symfony bundle for seamless integration
License
This library is released under the MIT License.