PHPackages                             qh-8/laravel-snowflake - 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. qh-8/laravel-snowflake

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

qh-8/laravel-snowflake
======================

Generate Snowflake Identifier for Laravel

v1.1.2(1y ago)6181MITPHPPHP ^8.2

Since Sep 16Pushed 1y ago1 watchersCompare

[ Source](https://github.com/qh-8/laravel-snowflake)[ Packagist](https://packagist.org/packages/qh-8/laravel-snowflake)[ RSS](/packages/qh-8-laravel-snowflake/feed)WikiDiscussions 1.x Synced 1mo ago

READMEChangelog (2)Dependencies (5)Versions (6)Used By (0)

Laravel Snowflake Id Generator
==============================

[](#laravel-snowflake-id-generator)

[![Latest Version on Packagist](https://camo.githubusercontent.com/b37f10073df15f6c66ce8a873ae1a178f9ae88787f2a8287b4684105db2d85f5/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f71682d382f6c61726176656c2d736e6f77666c616b652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/qh-8/laravel-snowflake)[![Total Downloads](https://camo.githubusercontent.com/17b43a31ede07c453d83f6280c30683f1c35f47c555a4991552e7f7b27c05503/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f71682d382f6c61726176656c2d736e6f77666c616b652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/qh-8/laravel-snowflake)[![GitHub Actions](https://github.com/qh-8/laravel-snowflake/actions/workflows/tests.yml/badge.svg)](https://github.com/qh-8/laravel-snowflake/actions/workflows/tests.yml/badge.svg)

A Laravel package to generate unique snowflake ids.

Forked from [kra8/laravel-snowflake](https://github.com/kra8/laravel-snowflake).

Requirements
------------

[](#requirements)

- Laravel 10 or higher

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

[](#installation)

```
composer require qh-8/laravel-snowflake
```

Usage
-----

[](#usage)

Using the `Snowflake` class to generate and decode snowflake ids.

```
use Qh\LaravelSnowflake\Snowflake;

$snowflake = app(Snowflake::class)->generate(); // or via Facade: Snowflake::generate()

// 93977444276639021

$data = app(Snowflake::class)->decode(93977444276639021); // or via Facade: Snowflake::decode(int $id)

//[
//  'binary_length' => 57,
//  'binary' => '101001101110111111111110011010111000000100001010100101101',
//  'binary_timestamp' => '10100110111011111111111001101011100',
//  'binary_sequence' => '010100101101',
//  'binary_worker_id' => '00001',
//  'binary_datacenter_id' => '00001',
//  'timestamp' => 22405968732,
//  'sequence' => 1325,
//  'worker_id' => 1,
//  'datacenter_id' => 1,
//  'epoch' => 1704067200000,
//  'datetime' => '2024-09-16T07:52:48+00:00',
//]
```

Using in the eloquent model:

```
use \Qh\LaravelSnowflake\HasSnowflakeIds;

class User extends Model
{
    use HasSnowflakeIds;

    //
}
```

Please note that the `id` column in the table should be a `BIGINT` type.

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Dinh Quoc Han](https://github.com/dinhquochan)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE) for more information.

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance36

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 85.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 ~2 days

Total

5

Last Release

597d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/03c4e5a3dbdbd2e2c83daba8b38e2cb15cab2d0bcce1395ce48d326d1406df82?d=identicon)[dinhquochan](/maintainers/dinhquochan)

---

Top Contributors

[![dinhquochan](https://avatars.githubusercontent.com/u/9979458?v=4)](https://github.com/dinhquochan "dinhquochan (6 commits)")[![duysolo](https://avatars.githubusercontent.com/u/10369102?v=4)](https://github.com/duysolo "duysolo (1 commits)")

###  Code Quality

TestsPHPUnit

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/qh-8-laravel-snowflake/health.svg)

```
[![Health](https://phpackages.com/badges/qh-8-laravel-snowflake/health.svg)](https://phpackages.com/packages/qh-8-laravel-snowflake)
```

###  Alternatives

[barryvdh/laravel-ide-helper

Laravel IDE Helper, generates correct PHPDocs for all Facade classes, to improve auto-completion.

14.9k123.0M687](/packages/barryvdh-laravel-ide-helper)[orchestra/canvas

Code Generators for Laravel Applications and Packages

21017.2M158](/packages/orchestra-canvas)[kirschbaum-development/commentions

A package to allow you to create comments, tag users and more

12369.2k](/packages/kirschbaum-development-commentions)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)[glhd/special

1929.4k](/packages/glhd-special)[bjuppa/laravel-blog

Add blog functionality to your Laravel project

483.3k2](/packages/bjuppa-laravel-blog)

PHPackages © 2026

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