th3mouk/audit-trail-bundle
A Symfony bundle that automatically logs Doctrine entity changes, recording who created, updated, or deleted records and keeping a searchable history of modifications for compliance, auditing, and debugging.
This is a pre-1.0 audit trail package (v0.1.2), so treat the API as unstable and pin an exact version in composer.json ("th3mouk/audit-trail-bundle": "0.1.*") rather than floating it.
composer require th3mouk/audit-trail-bundle, then publish the config and migrations (php artisan vendor:publish --tag=...) and run php artisan migrate. The package needs its audit_entries (or equivalently named) table plus a polymorphic link back to your models.Invoice or User), perform a create/update/delete, and inspect the generated entries. Confirm that a freshly created model's DB-assigned primary key is present in the create entry — this is exactly the bug fixed in v0.1.2, so verify it on your setup before trusting the trail.Because it's 0.1.x, skim the trait/interface contracts directly in vendor/ — docs are thin at this stage.
auth(). Set this explicitly (and null it in console/queue contexts) so background jobs and artisan commands don't record a stale or wrong actor. Wrap this in a small AuditContext service or middleware.$model->auditEntries) and render a timeline. Filter by event type (created/updated/deleted) and eager-load to avoid N+1.old/new JSON payloads in a presenter rather than in the controller. Keep field-label mapping in one place so the UI stays readable.update. This keeps the trail semantic.JobProcessing listener before the job runs.v0.1.2 fix matters for create entries: previously the create entry didn't reliably carry the database-assigned key (auto-increment/UUID generated by the DB). If you were backfilling or joining audit entries to records by key, upgrade and re-check historical rows — old create entries may be missing the key and won't retroactively gain it.0.x semver = breaking changes allowed: read every changelog. Pin versions and upgrade deliberately; don't assume patch releases are inert.Model::where(...)->update(), insert(), upsert, and raw queries won't fire the events the package listens to. Use save()/delete() per model, or log manually, if those changes must be audited.deleted/restored the way you expect — these are separate events in Laravel and easy to miss.sync(): many-to-many changes often don't produce useful entries. Decide explicitly whether you need them and handle via manual entries if so.(auditable_type, auditable_id) and on the event/created-at columns; consider pruning or archiving old entries.php artisan config:clear — a stale cached config is a classic "why isn't it auditing?" cause.assertDatabaseHas against the audit table and a fake authenticated user; add a regression test asserting the create entry contains the model's key (the v0.1.2 behaviour) so a future refactor can't silently drop it.0.x.How can I help you explore Laravel packages today?