Download the PHP package mpociot/versionable without Composer

On this page you can find all versions of the php package mpociot/versionable. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package versionable

Versionable

Laravel Model versioning made easy

image image image codecov.io Scrutinizer Code Quality Build Status

Keep track of all your model changes and revert to previous versions of it.

Installation

You can install via composer:

Run the migrations.

Alternatively, publish the migrations.

Then customize and run them.

Usage

Let the Models you want to set under version control use the VersionableTrait.

That's it!

Every time you update your model, a new version containing the previous attributes will be stored in your database.

All timestamps and the optional soft-delete timestamp will be ignored.

Adding versions to existing data

Versionable creates a version on update() of the updated model. So, if you're installing this on an already existing application, you may want to create a version of the current model:

If no version exists, this will create the initial version.

If you want to do this for all instances of a model:

Exclude attributes from versioning

Sometimes you don't want to create a version every time an attribute on your model changes. For example your User model might have a last_login_at attribute. I'm pretty sure you don't want to create a new version of your User model every time that user logs in.

To exclude specific attributes from versioning, add a new array property to your model named dontVersionFields.

Hidden fields

There are times you might want to include hidden fields in the version data. You might have hidden the fields with the visible or hidden properties in your model.

You can have those fields that are typically hidden in the rest of your project saved in the version data by adding them to the versionedHiddenFields property of the versionable model.

Maximum number of stored versions

You can control the maximum number of stored versions per model. By default, there will be no limit and all versions will be saved. Depending on your application, this could lead to a lot of versions, so you might want to limit the amount of stored versions.

You can do this by setting a $keepOldVersions property on your versionable models:

Retrieving all versions associated to a model

To retrieve all stored versions use the versions attribute on your model.

This attribute can also be accessed like any other Laravel relation, since it is a MorphMany relation.

Getting a diff of two versions

If you want to know, what exactly has changed between two versions, use the version model's diff method.

The diff method takes a version model as an argument. This defines the version to diff against. If no version is provided, it will use the current version.

The result will be an associative array containing the attribute name as the key, and the different attribute value.

Revert to a previous version

Saving versions is pretty cool, but the real benefit will be the ability to revert to a specific version.

There are multiple ways to do this.

Revert to the previous version

You can easily revert to the version prior to the currently active version using:

Revert to a specific version ID

You can also revert to a specific version ID of a model using:

Disable versioning

In some situations you might want to disable versioning a specific model completely for the current request.

You can do this by using the disableVersioning and enableVersioning methods on the versionable model.

Use different version table

Some times we want to have models versions in differents tables. By default versions are stored in the table 'versions', defined in Mpociot\Versionable\Version::$table.

To use a different table to store version for some model we have to change the table name. To do so, create a model that extends Mpociot\Versionable\Version and set the $table property to another table name.

In the model that you want it use this specific versions table, use the VersionableTrait Trait and add the property $versionClass with value the specific version model.

And do not forget to create a migration for this versions table, exactly as the default versions table.

License

Versionable is free software distributed under the terms of the MIT license.


All versions of versionable with dependencies

PHP Build Version
Package Version
Requires php Version >=7.1.0 || >=7.2.5 || >=8.0 || >=8.1 || >= 8.2
illuminate/support Version ~5.3 || ^6.0 || ^7.0 || ^8.0 || ^9.0 || ^10.0 || ^11.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package mpociot/versionable contains the following files

Loading the files please wait ....