PHPackages                             laravel-enso/versions - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. laravel-enso/versions

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

laravel-enso/versions
=====================

Prevents update conflicts using the optimistic lock pattern in Laravel

2.0.6(2mo ago)010.2k↑38.3%3MITPHPPHP &gt;=7.4.0

Since Sep 12Pushed 2mo ago4 watchersCompare

[ Source](https://github.com/laravel-enso/versions)[ Packagist](https://packagist.org/packages/laravel-enso/versions)[ Docs](https://github.com/laravel-enso/versions)[ RSS](/packages/laravel-enso-versions/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependenciesVersions (17)Used By (0)

Versions
========

[](#versions)

[![License](https://camo.githubusercontent.com/38181ff017520917090f3eba9695a7ad04e85cd5416006c840eed232886f2fa6/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d3130623938312e737667)](https://github.com/laravel-enso/versions/blob/master/LICENSE)[![Stable](https://camo.githubusercontent.com/d07006250e35f8c4996772bc936c2f331b33abde2917229344c7db17cc1ee4cb/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f737461626c652d322e302e302d3235363365622e737667)](https://packagist.org/packages/laravel-enso/versions)[![Downloads](https://camo.githubusercontent.com/9d1e2d7831a80b1e117929c9b0d3119607064b2d17625a38be0321c800c0b89b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646d2f6c61726176656c2d656e736f2f76657273696f6e732e737667)](https://packagist.org/packages/laravel-enso/versions)[![PHP](https://camo.githubusercontent.com/30c907835ccbb7c3e0ecd4af460efb8b2dcef7fe59e21ea7ecdfa6839a0b5d51/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d372e342532422d3737376262342e737667)](https://github.com/laravel-enso/versions/blob/master/composer.json)[![Issues](https://camo.githubusercontent.com/901930d418bbd79fe10bfdda8868900c5804dcd69ba3548682ae8db2576749d7/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f6c61726176656c2d656e736f2f76657273696f6e732e737667)](https://github.com/laravel-enso/versions/issues)[![Merge Requests](https://camo.githubusercontent.com/1c56f25408db0c230402c71467120e2418547234a8e84580927dca9777abaf61/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732d70722f6c61726176656c2d656e736f2f76657273696f6e732e737667)](https://github.com/laravel-enso/versions/pulls)

Description
-----------

[](#description)

Versions prevents concurrent-update conflicts through an optimistic-lock field on Eloquent models.

The package increments a version column on each update, checks the persisted version under a database lock before writing, and throws an HTTP 409 conflict when the record was modified after it was loaded.

It can work independently of the Laravel Enso ecosystem.

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

[](#installation)

Install the package:

```
composer require laravel-enso/versions
```

Add the trait to a model that has a version column:

```
use Illuminate\Database\Eloquent\Model;
use LaravelEnso\Versions\Traits\Versions;

class Invoice extends Model
{
    use Versions;
}
```

The trait expects a `version` integer column by default. To use another column name, define a protected `$versioningAttribute` property on the model.

Features
--------

[](#features)

- Sets the version column to `1` when creating a model.
- Starts a database transaction before updates and checks the persisted version under a lock.
- Increments the version automatically when the update is accepted.
- Throws a `ConflictHttpException` when another process already changed the record.

Usage
-----

[](#usage)

Manual version check:

```
$invoice->checkVersion($request->integer('version'));
```

Custom version column:

```
class Invoice extends Model
{
    use Versions;

    protected string $versioningAttribute = 'lock_version';
}
```

If the check fails, the package throws `LaravelEnso\\Versions\\Exceptions\\Version`, which extends Symfony's `ConflictHttpException`.

API
---

[](#api)

### Trait

[](#trait)

- `LaravelEnso\\Versions\\Traits\\Versions`

Main methods:

- `checkVersion(?int $version = null): void`

Lifecycle hooks:

- `bootVersions()`

### Exception

[](#exception)

- `LaravelEnso\\Versions\\Exceptions\\Version`

Factory method:

- `Version::recordModified(string $class)`

Depends On
----------

[](#depends-on)

This package has no Enso package dependencies and can be used independently.

Contributions
-------------

[](#contributions)

are welcome. Pull requests are great, but issues are good too.

Thank you to all the people who already contributed to Enso!

License
-------

[](#license)

[MIT](https://github.com/laravel-enso/versions/blob/master/LICENSE)

###  Health Score

52

—

FairBetter than 96% of packages

Maintenance86

Actively maintained with recent releases

Popularity26

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 51.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~172 days

Recently: every ~505 days

Total

15

Last Release

73d ago

Major Versions

1.1.2 → 2.0.02020-06-25

PHP version history (3 changes)1.0.0PHP &gt;=7.1.0

1.0.3PHP &gt;=7.3.0

1.1.0PHP &gt;=7.4.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/16073274?v=4)[Adrian Ocneanu](/maintainers/aocneanu)[@aocneanu](https://github.com/aocneanu)

---

Top Contributors

[![aocneanu](https://avatars.githubusercontent.com/u/16073274?v=4)](https://github.com/aocneanu "aocneanu (15 commits)")[![gandesc](https://avatars.githubusercontent.com/u/14071925?v=4)](https://github.com/gandesc "gandesc (7 commits)")[![raftx24](https://avatars.githubusercontent.com/u/10864136?v=4)](https://github.com/raftx24 "raftx24 (6 commits)")[![StyleCIBot](https://avatars.githubusercontent.com/u/11048387?v=4)](https://github.com/StyleCIBot "StyleCIBot (1 commits)")

---

Tags

ensolaravellaravel-ensotraitversionversioningversionstraitoptimistic-locklaravel-enso

### Embed Badge

![Health badge](/badges/laravel-enso-versions/health.svg)

```
[![Health](https://phpackages.com/badges/laravel-enso-versions/health.svg)](https://phpackages.com/packages/laravel-enso-versions)
```

###  Alternatives

[jean85/pretty-package-versions

A library to get pretty versions strings of installed dependencies

1.3k315.9M84](/packages/jean85-pretty-package-versions)[nette/robot-loader

🍀 Nette RobotLoader: high performance and comfortable autoloader that will search and autoload classes within your application.

89955.0M360](/packages/nette-robot-loader)[sllh/composer-versions-check

Checks if packages are up to date to last major versions after update

2392.4M16](/packages/sllh-composer-versions-check)[kkszymanowski/traitor

Add a trait use statement to existing PHP class

1305.6M16](/packages/kkszymanowski-traitor)[laravel-enso/tables

Server-side data tables and export backend for Laravel Enso

63355.1k83](/packages/laravel-enso-tables)[awcodes/filament-versions

A mostly useless package to display framework versions at the bottom of the navigation panel.

4476.5k8](/packages/awcodes-filament-versions)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
