Search by

mj-zana / audit

mjnable

Content revisions for Zana applications: who changed what and when, per locale, with history and restore

v2.5.0 2026-10-26 14:55 UTC

This package is auto-updated.

Last update: 2026-10-27 16:28:52 UTC


README

Content revisions for Zana applications: every published version of a record, per locale, with its author, its date, a history and restore.

composer require mj-zana/audit

Register AuditServiceProvider and create the table in a migration:

DatabaseRevisionStore::createTable($connection);
$revisions->record('post', $post->id, 'fr', ['title' => $title, 'body' => $body]);

foreach ($revisions->history('post', $post->id, 'fr') as $revision) {
    // $revision->version, ->author, ->createdAt, ->diff($previous)
}

$data = $revisions->restore('post', $post->id, 'fr', 3);   // then save it to the post
  • Locales: versions are numbered per record and locale.
  • No duplicates: recording identical content again does nothing.
  • Author: the signed-in user with mj-zana/security. You can also pass one explicitly.
  • Restore: restoring records the old content as the newest version, with the note "Restored version N", so the history stays complete.
  • Storage: DatabaseRevisionStore (table audit.table), or your own RevisionStoreInterface.

License

MIT