Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Laravel Rewind

Laravel Rewind Laravel Package

avocet-shores/laravel-rewind

Full version control for Eloquent models: rewind, fast-forward, restore, diff, and query point-in-time state. Uses hybrid diffs + snapshots for efficient storage and fast reconstruction, with locking for safe concurrent writes, batching, queues, and pruning.

View on GitHub
Deep Wiki
Context7

Laravel Rewind adds full version control to your Eloquent models, letting you rewind, fast-forward, restore, diff, and query point-in-time state. It uses a hybrid storage engine (snapshots + diffs) to balance speed and storage, with configurable intervals to fit your workload.

  • Rewind/fast-forward/go-to any model version instantly
  • Hybrid snapshots + diffs for efficient storage and fast reconstruction
  • Thread-safe writes via cache-based locking for consistent version sequences
  • Non-destructive history: restores, edits, and pruning preserve the audit trail
  • Batch versioning to group changes across multiple models into one revision
Frequently asked questions about Laravel Rewind
How do I enable versioning for an Eloquent model in Laravel?
Use the `Rewindable` trait on your model and add a `current_version` column to your database table. Run the `rewind:install` Artisan command to create the versions table. Versioning is automatic for all updates unless explicitly skipped.
What’s the difference between snapshots and diffs in Laravel Rewind?
Rewind uses a hybrid approach: full snapshots are taken at configurable intervals (e.g., every 10 versions), while intermediate changes are stored as diffs. This balances storage efficiency with fast reconstruction—snapshots ensure quick rollbacks, while diffs minimize space usage.
Does Laravel Rewind work with Laravel 9/10/11, or only newer versions?
The package officially supports Laravel 9+. For Laravel 8 or older, you may need to manually adjust dependencies or use polyfills. Always check the [GitHub releases](https://github.com/avocet-shores/laravel-rewind/releases) for version-specific notes.
How do I handle high-write volumes (e.g., 1000+ updates/sec) without performance issues?
Enable queued versioning via `listener_should_queue` in your model’s `rewindable()` method. For non-critical updates, use `amendCurrentVersion()` to avoid creating new versions. Monitor queue backlogs and adjust worker capacity accordingly.
Can I restore a model to a previous version without affecting its current state?
Yes, use `Rewind::restore($model, $version)` to create a new version based on an older state while preserving the current version. This is non-destructive and maintains the full audit trail.
How does thread safety work in Laravel Rewind? Will concurrent writes corrupt version history?
Rewind uses cache-based locking to ensure thread safety. Each write acquires a lock to prevent version sequence breaks. Misconfigured lock timeouts (`on_lock_timeout`) could cause issues, but defaults log failures. For production, test with your expected concurrency levels.
What’s the best way to manage storage growth for long-lived models (e.g., user accounts)?
Use the `rewind:prune` Artisan command to automatically remove old versions. Configure retention policies via `snapshot_interval` and `keep` settings in your model. Schedule pruning jobs (e.g., daily) and monitor storage growth with database metrics.
Does Laravel Rewind support custom metadata or events for version changes?
Yes, extend the `RewindVersion` model to add custom fields. Use event hooks like `RewindVersionCreated` to trigger notifications, logs, or side effects. The package provides flexibility for integrating with your existing workflows.
How do I query or diff between two versions of a model?
Use `Rewind::diff($model, $version1, $version2)` to compare changes between versions. For querying historical states, use `Rewind::goTo($model, $version)` to load a model at a specific point in time, then inspect its attributes.
Are there alternatives to Laravel Rewind for versioning Eloquent models?
Alternatives include `spatie/laravel-activitylog` (for simpler audit logs) or `laravel-model-versions` (full snapshots). Rewind’s hybrid diff/snapshot approach is unique for balancing speed and storage, making it ideal for high-write applications needing fast rollbacks and compliance.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport