PHPackages                             ifullgaz/laravel-global-unique-id - 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. ifullgaz/laravel-global-unique-id

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

ifullgaz/laravel-global-unique-id
=================================

Assign globaly unique ids to models

1.0.1(3y ago)030MITPHPPHP &gt;=8.0

Since Jul 14Pushed 3y ago1 watchersCompare

[ Source](https://github.com/ifullgaz/laravel-global-unique-id)[ Packagist](https://packagist.org/packages/ifullgaz/laravel-global-unique-id)[ RSS](/packages/ifullgaz-laravel-global-unique-id/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (3)Versions (3)Used By (0)

Laravel GlobalUniqueId
----------------------

[](#laravel-globaluniqueid)

[![Unit Tests](https://github.com/ifullgaz/laravel-global-unique-id/workflows/CI/badge.svg)](https://github.com/ifullgaz/laravel-global-unique-id/workflows/CI/badge.svg)[![License](https://camo.githubusercontent.com/a062c5570846a4f375dfce70319734c14064aa38ce5afd8220e72d0fdf4bfc8e/68747470733a2f2f706f7365722e707567782e6f72672f6966756c6c67617a2f6c61726176656c2d676c6f62616c2d756e697175652d69642f6c6963656e7365)](http://choosealicense.com/licenses/mit/)[![Latest Stable Version](https://camo.githubusercontent.com/be8593e942e2f1b34d3ee787dacd747af22862b8566430c353c89c08561d6592/68747470733a2f2f706f7365722e707567782e6f72672f6966756c6c67617a2f6c61726176656c2d676c6f62616c2d756e697175652d69642f76)](https://packagist.org/packages/ifullgaz/laravel-global-unique-id)[![Latest Unstable Version](https://camo.githubusercontent.com/fe15d452dd78ee47ba9cc5c0fc2c7317f31ba35f7d38adf67d78978b658197c3/68747470733a2f2f706f7365722e707567782e6f72672f6966756c6c67617a2f6c61726176656c2d676c6f62616c2d756e697175652d69642f762f756e737461626c65)](https://packagist.org/packages/ifullgaz/laravel-global-unique-id)[![PHP Version Require](https://camo.githubusercontent.com/bd882a176a1f03147d2e172ace62f555cec5e4374b3979aeeb1175095b1543c5/68747470733a2f2f706f7365722e707567782e6f72672f6966756c6c67617a2f6c61726176656c2d676c6f62616c2d756e697175652d69642f726571756972652f706870)](https://packagist.org/packages/ifullgaz/laravel-global-unique-id)[![Total Downloads](https://camo.githubusercontent.com/f4bcd82de271d0045ac7225e74cb056c5a2975654e9bb5757cbe4c9e2c732dcd/68747470733a2f2f706f7365722e707567782e6f72672f6966756c6c67617a2f6c61726176656c2d676c6f62616c2d756e697175652d69642f646f776e6c6f616473)](https://packagist.org/packages/ifullgaz/laravel-global-unique-id)

Trait to generate 64 bit globally unique ids for all running PHP processes. The unique ID is a 64-bits integer number. Ids are guaranteed to be time ordered. The content of the integer is as follows, for example:

```
63 62 ------------------------------------------ 21 20 ------------ 9 8 ---------- 0
 0           42 bits time in milliseonds                 12 bits          9 bits
            140 years until rollover to 0           unique machine id  local counter

```

Note: bit 63 must be 0 since PHP doesn't support unsigned integers.

In this example, each PHP process can create up to 512 new ids per millisecond before any collision occurs. A total of 2,097,152 new ids could be created per milliseconds in this system.

Note: JS cannot process integers larger than 2^53-1 at this time. A good compromise is to use 42-6-5 bits as values, allowing for 64 \* 32 = 2048 new ids per milliseconds. In case this is not appropriate (not enough ids/sec), the following snippet may be used to parse the raw response before deserialization:

```
function (data) {
    data = data.replace(/:\s*(-?\d+),/g, (match, $1) => {
        if ($1  env('GLOBAL_UNIQUE_ID_START_DATE', '01/01/2022'),

/*
|--------------------------------------------------------------------------
| Timestamp size
|--------------------------------------------------------------------------
|
| Number of bits to use for the timestamp.
| The more bits used, the larger the date range
| eg: 42 bits -> ~140 years, 41 bits -> ~70 years...
|
*/
'timestamp_size' => env('GLOBAL_UNIQUE_ID_TIMESTAMP_SIZE', 42),

/*
|--------------------------------------------------------------------------
| Machine id size
|--------------------------------------------------------------------------
|
| Number of bits to use for the machine id.
| The more bits used, the more PHP processes can run concurrently.
| eg: 11 bits -> 2^11 (2048) concurrent processes
|
*/
'machine_id_size' => env('GLOBAL_UNIQUE_ID_MACHINE_ID_SIZE', 11),

/*
|--------------------------------------------------------------------------
| Counter size
|--------------------------------------------------------------------------
|
| Number of bits to use for the local counter.
| The more bits used, the higher the local counter can go.
| eg: 10 bits -> 2^10 (1024) values
|
*/
'counter_size' => env('GLOBAL_UNIQUE_ID_COUNTER_SIZE', 10),

```

Usage
-----

[](#usage)

Add the trait to a class that has a numerical primary key as such:

```
use Ifullgaz\GlobalUniqueId\Models\Traits\GlobalUniqueId;

class MyClass extends Model
{
    use GlobalUniqueId;
}
```

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~2 days

Total

2

Last Release

1396d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/452499a47f668471409951fd01bba86687920f98960f75dd46181002f8e04ac0?d=identicon)[ifullgaz](/maintainers/ifullgaz)

---

Top Contributors

[![ifullgaz](https://avatars.githubusercontent.com/u/3903636?v=4)](https://github.com/ifullgaz "ifullgaz (3 commits)")

---

Tags

laravelglobalid

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/ifullgaz-laravel-global-unique-id/health.svg)

```
[![Health](https://phpackages.com/badges/ifullgaz-laravel-global-unique-id/health.svg)](https://phpackages.com/packages/ifullgaz-laravel-global-unique-id)
```

###  Alternatives

[tonysm/globalid-laravel

Identify app models with a URI. Inspired by the globalid gem.

45101.6k2](/packages/tonysm-globalid-laravel)[highideas/laravel-users-online

This package will provide an online users management.

203113.2k1](/packages/highideas-laravel-users-online)[stephenjude/filament-blog

Filament Blog Builder

20317.8k](/packages/stephenjude-filament-blog)[ralphjsmit/laravel-helpers

A package containing handy helpers for your Laravel-application.

13704.6k2](/packages/ralphjsmit-laravel-helpers)[datomatic/nova-detached-actions

A Laravel Nova tool to allow for placing actions in the Nova toolbar detached from the checkbox selection mechanism.

11229.2k](/packages/datomatic-nova-detached-actions)

PHPackages © 2026

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