The missing audit log library for PHP
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.
The library is architected around two core concepts:
These services are implemented by Providers. Each provider handles a specific storage technology (Doctrine ORM, Eloquent, etc.).
flowchart TD
APP["Your Application"] --> AUDITOR
subgraph AUDITOR["AUDITOR"]
direction TB
subgraph CONFIG["Configuration"]
direction LR
enabled
timezone
userProvider
securityProvider
roleChecker
end
subgraph PROVIDER["Provider (e.g. DoctrineProvider)"]
direction TB
subgraph AUDITING["AuditingService(s)"]
EMA["EntityManager A
(source data)"]
end
subgraph STORAGE["StorageService(s)"]
EMX["EntityManager X
(audit storage)"]
end
AUDITING --> TP
STORAGE --> TP
TP["TransactionProcessor
Track inserts, updates, deletes, relations
Build payload (diffs, blame, extra_data = null)"]
end
subgraph EVENTS["EventDispatcher"]
direction TB
TP --> LE
LE["LifecycleEvent
payload (diffs, blame, extra_data)
entity (the audited object)"]
LE --> LISTENER
LISTENER["Your Listener(s) — optional
Enrich extra_data from entity state"]:::optional
end
end
LISTENER --> DB
DB[("Audit Tables
users_audit, posts_audit, ...
Columns: type, diffs, extra_data, blame, ...")]
classDef optional stroke-dasharray: 5 5
AuditingService detects the changeTransactionProcessor computes diffs and prepares audit data (with extra_data = null)LifecycleEvent is dispatched with the audit payload and the entity objectextra_data in the payloadStorageService persists the audit entry to the database| Provider | Package | Storage technology |
|---|---|---|
| DoctrineProvider | auditor-doctrine-provider | Doctrine ORM / DBAL |
Need a different backend? See Building a Custom Provider.
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 | Status | Requirements |
|---|---|---|
| 5.x | Active development 🚀 | PHP >= 8.4, Symfony >= 8.0 |
| 4.x | Active support | PHP >= 8.4, Symfony >= 8.0, Doctrine DBAL >= 4.0, Doctrine ORM >= 3.2 |
| 3.x | End of Life | 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 |
This library is released under the MIT License.
How can I help you explore Laravel packages today?