Download the PHP package sbarre/eloquent-versioned without Composer

On this page you can find all versions of the php package sbarre/eloquent-versioned. 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 eloquent-versioned

Eloquent Versioned

Adds transparent versioning support to Laravel 5.2's Eloquent ORM.

WARNING: This repository is currently super-duper experimental. I will gladly accept pull requests and issues, but you probably shouldn't use this in production, and the interfaces may change without notice (although major changes will bump the version).

It was also recently updated to bring global scopes in line with Laravel 5.2 so if you are not yet on 5.2, stick with release 0.0.7.

When using this trait (and with a table that includes the required fields), saving your model will actually create a new row instead, and increment the version number.

Using global scopes, old versions are ignored in the standard ORM operations (selects, updates, deletes) and relations (hasOne, hasMany, belongsTo, etc).

The package also provides some special methods to include old versions in queries (or only query old versions) which can be useful for showing a model's history, or the like.

Installation

To add via Composer:

Use the --no-dev flag to avoid pulling down all the testing dependencies (like the entire Laravel framework).

Migrations

Versioned models require that your database table contain 3 fields to handle the versioning.

If you are creating a new table, or if you are changing an existing table, include the following lines in the up() method of the migration:

If your migration was altering an existing table, you should include these lines in the down() method of your migration:

Caveats

If you change the constants in EloquentVersioned\VersionedBuilder to rename the columns, remember to change them in your migrations as well.

Usage

In your Eloquent model class, start by adding the use statement for the Trait:

When the trait boots it will apply the proper scope, and provides overrides on various Eloquent methods to support versioned records.

Once the trait is applied, you use your models as usual, with the standard queries behaving as usual.

This would then output (for example):

The actual database row looks like this:

Then if you change the model and save:

This would then output:

The model mutates the model_id column into id, and hides some of the version-specific columns. In reality this is actually the same database row that now looks like this:

While a new row is inserted to save our previous version, which now looks like this:

So the is_current_version property is what the global scope is applied against, limiting all select queries to only records where is_current_version = 1.

Calling save() on a model replicates the original version into a new row (with is_current_version = 0), then increments the version_id property on our current model, changes the appropriate timestamps, and saves it.

If you are making a very minor change to a model and you don't want to create a new version, you can call saveMinor() instead.

Methods for dealing with old versions

If you want to retrieve a list of all versions of a model (or include old versions in a bigger query):

If run after our example above, this would return an array with 2 models.

You can also retrieve a list of only old models by using:

Otherwise, the rest of Eloquent's ORM operations should work as usual, including the out-of-the-box relations.

Methods for moving through a model's versions

If you want to navigate through all of model's versions, in a linked-list manner:

If you are at the most recent version, getNextModel() will return null and likewise if you are at the oldest version, getPreviousModel() will return null.

Support & Roadmap

As indicated at the top, this package is still very experimental and is under active development. The current roadmap includes test coverage and more extensive real-world testing, so pull requests and issues are always welcome!


All versions of eloquent-versioned with dependencies

PHP Build Version
Package Version
Requires php Version >=5.4
illuminate/database Version ~5.2
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 sbarre/eloquent-versioned contains the following files

Loading the files please wait ....