PHPackages                             plank/snapshots - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. plank/snapshots

ActiveLibrary[Database &amp; ORM](/categories/database)

plank/snapshots
===============

Snapshot Laravel Models

v12.10.0(2mo ago)75.0k↑42.9%1[2 PRs](https://github.com/plank/snapshots/pulls)MITPHPPHP ^8.2CI passing

Since Nov 6Pushed 2mo ago2 watchersCompare

[ Source](https://github.com/plank/snapshots)[ Packagist](https://packagist.org/packages/plank/snapshots)[ Docs](https://github.com/plank/snapshots)[ RSS](/packages/plank-snapshots/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (24)Versions (119)Used By (0)

[![](art/snapshots.png)](https://plank.co)

[![PHP Version Support](https://camo.githubusercontent.com/d20d90a64af07e1b16f2ca8573d310e17a32d5dcece1cd057bf031d59d136e87/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f706c616e6b2f736e617073686f74733f636f6c6f723d253233666165333730266c6162656c3d706870266c6f676f3d706870266c6f676f436f6c6f723d253233666666)](https://packagist.org/packages/plank/snapshots)[![PHP Version Support](https://camo.githubusercontent.com/fc4d93e10f6522f6943542eacf83644cde8928ff9f57cc6b2be93027b8dcd70e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c61726176656c2d31302e782c25323031312e782d2532333433643339393f636f6c6f723d253233663165646539266c6f676f3d6c61726176656c266c6f676f436f6c6f723d253233666666666666)](https://laravel.com/docs/11.x/releases#support-policy)[![GitHub Workflow Status](https://camo.githubusercontent.com/6ed29bfb40b467f58715b578d3ef6a94865dd4c2c3f8071b0ed871f8cd291039/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f706c616e6b2f736e617073686f74732f72756e2d74657374732e796d6c3f6272616e63683d6d61696e2626636f6c6f723d253233626663396264266c6162656c3d72756e2d7465737473266c6f676f3d676974687562266c6f676f436f6c6f723d253233666666)](https://github.com/plank/snapshots/actions?query=workflow%3Arun-tests)[![](https://camo.githubusercontent.com/f07127177ee1cba1c37f065b59efcfc3206667b522d3133a709b672353c8c3a7/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636c696d6174652f636f7665726167652f706c616e6b2f736e617073686f74733f636f6c6f723d253233666639333736266c6162656c3d74657374253230636f766572616765266c6f676f3d636f64652d636c696d617465266c6f676f436f6c6f723d253233666666)](https://codeclimate.com/github/plank/snapshots/test_coverage)[![](https://camo.githubusercontent.com/3fcb47c8747cfd2de4e5fc33c31656f67869db0464291c9d2a86f1e232f475c0/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636c696d6174652f6d61696e7461696e6162696c6974792f706c616e6b2f736e617073686f74733f636f6c6f723d253233353238636666266c6162656c3d6d61696e7461696e61626c696c697479266c6f676f3d636f64652d636c696d617465266c6f676f436f6c6f723d253233666666)](https://codeclimate.com/github/plank/snapshots/maintainability)

Laravel Snapshots
=================

[](#laravel-snapshots)

⚠️ Package is under active development. Do not use in production. ⚠️

Snapshots is a Laravel package that allows you to version the content of your app by replicating database tables and their content. Each snapshot represents a browseable version of your app's content at a specific point in time. By changing the active version of your app, you can view your app's content at a previous version.

The main goal of this package is for it to perform robust versioning of your content, but stay out of your way. You should be able to use it without having to change your existing codebase. It should be easy to install and configure, and it should be easy to use.

Table of Contents
-----------------

[](#table-of-contents)

- [Installation](#installation)
- [Quick Start](#quick-start)
- [Configuration](#configuration)
    - [Version Model](#version-model)
    - [Repository](#repository)
    - [Auto Migration](#auto-migration)
    - [Auto Copy](#auto-copy)
- [Usage](#usage)
    - [Versions](#versions)
        - [Contract and Model](#contract-and-model)
            - [Events](#events)
        - [Repository](#version-repository)
    - [Migrations](#migrations)
        - [SnapshotMigration](#snapshotmigration)
        - [SnapshotMigrator](#snapshotmigrator)
            - [Limitations](#limitations)
    - [Models](#models)
- [Contributing](#contributing)
- [Credits](#credits)
- [License](#license)
- [Security Vulnerabilities](#security-vulnerabilities)
- [Plank](#check-us-out)

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require plank/snapshots
```

You can use the package's install command to complete the installation:

```
php artisan snapshots:install
```

Quick Start
-----------

[](#quick-start)

Once the installation has completed, to begin using the package:

1. Make all migrations for versioned content implement `Plank\Snapshots\Migrator\SnapshotMigration`.
2. Make all models representing versioned content implement `Plank\Snapshots\Contracts\Versioned` and use the `Plank\Snapshots\Concerns\AsVersionedContent` trait.
3. Make all models that are not versioned, but have a relation to versioned content use the `Plank\Snapshots\Concerns\InteractsWithVersionedContent` trait.
4. Create a middleware to set the active version of your app based on the request.

Middleware example:

```
