mj-zana / audit
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
Requires
- php: ^8.5
- mj-zana/core: ^2.4
- mj-zana/database: ^2.0
Requires (Dev)
- mj-zana/security: ^2.2
- phpstan/phpstan: ^2.1
- phpunit/phpunit: ^11.5
Suggests
- mj-zana/security: To record the signed-in user as the author
Provides
None
Conflicts
None
Replaces
None
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(tableaudit.table), or your ownRevisionStoreInterface.
License
MIT