PHPackages                             reishou/unique-identity - 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. reishou/unique-identity

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

reishou/unique-identity
=======================

Generator unique identity 64 bits and combine with laravel eloquent.

1.0.0(5y ago)393MITPHPPHP ^7.3|^8.0

Since Mar 6Pushed 5y ago1 watchersCompare

[ Source](https://github.com/reishou/unique-identity)[ Packagist](https://packagist.org/packages/reishou/unique-identity)[ RSS](/packages/reishou-unique-identity/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (1)Dependencies (3)Versions (3)Used By (0)

unique-identity
---------------

[](#unique-identity)

Generator unique identity 64 bits and combine with laravel eloquent.

[![Latest Version on Packagist](https://camo.githubusercontent.com/69c776a74315510fa64d16efd51cc25931d0e8de1734e5b031decac8fb5fd380/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f72656973686f752f756e697175652d6964656e746974792e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/reishou/unique-identity)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Build Status](https://github.com/reishou/unique-identity/actions/workflows/php.yml/badge.svg)](https://github.com/reishou/unique-identity/actions)[![Total Downloads](https://camo.githubusercontent.com/4440f024b3ede43420e6f9321bec843453507ba803599d472b05f5e7d0bf1424/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f72656973686f752f756e697175652d6964656e746974792e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/reishou/unique-identity)

- [Overview](#overview)
- [Installation](#installation)
- [Usage](#usage)
    - [Automatic when eloquent boot creating](#automatic-when-eloquent-boot-creating)
    - [Manual generate list uid](#manual-generate-list-uid)
- [License](#license)
- [Changelog](#changelog)

### Overview

[](#overview)

This project inspires from the article [Sharding &amp; IDs at Instagram](https://instagram-engineering.com/sharding-ids-at-instagram-1cf5a71e5a5c). With it, you can create uid for your table:

- 64-bits length.
- sortable by time.

### Installation

[](#installation)

Require this package with composer using the following command:

```
composer require reishou/unique-identity
```

Laravel uses Package Auto-Discovery, so doesn't require you to manually add the ServiceProvider.

Publish the config file with:

```
php artisan vendor:publish --provider="Reishou\UniqueIdentity\UidServiceProvider"
```

You can change `entity_table` name in `config/uid.php` (default `entity_sequences`). Then run command generate migration:

```
php artisan uid:table
```

After the migration has been generated you can create the `entity_table` by running:

```
php artisan migrate

```

### Usage

[](#usage)

#### Automatic when eloquent boot creating

[](#automatic-when-eloquent-boot-creating)

Your Eloquent models should use the `Reishou\UniqueIdentity\HasUid` trait.

```
