PHPackages                             hafael/laraflake - 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. hafael/laraflake

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

hafael/laraflake
================

Laravel Package based on Twitter Snowflake ID Generator (64 bit ID).

v1.2.5(6y ago)287.9k6[1 issues](https://github.com/hafael/laraflake/issues)1Apache-2.0PHPPHP &gt;=5.3.0CI failing

Since Jul 22Pushed 1y ago1 watchersCompare

[ Source](https://github.com/hafael/laraflake)[ Packagist](https://packagist.org/packages/hafael/laraflake)[ RSS](/packages/hafael-laraflake/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (9)Dependencies (4)Versions (12)Used By (1)

[![](https://camo.githubusercontent.com/2bedf63f24cda7efab02da955dc11fb7ef8a060e2f26b73c33a7aac84529b8a3/68747470733a2f2f6769746875622d6164732e73332e65752d63656e7472616c2d312e616d617a6f6e6177732e636f6d2f737570706f72742d756b7261696e652e7376673f743d31)](https://supportukrainenow.org)

LaraFlake
=========

[](#laraflake)

---

LaraFlake is a Laravel 5.x Package based on Twitter Snowflake ID Generator (64 bit ID).

- Generate unique identifiers like **4685142323047173636** (64bit)
- 41bit for time
- 10bits for shard database identifier from 1 to 512
- 12bits for randomic number from 1 to 2048

Only supports MySQL database. :(
Waiting for your pull request to solve this issue...

### How to use

[](#how-to-use)

Run the composer require command from your terminal:

```
$ composer require hafael/laraflake
```

Open rootproject/config/app.php and register the required service provider **above** your application providers.

```
'providers' => [
    /*
     * Application Service Providers...
     */
    ...
    Hafael\LaraFlake\LaraFlakeServiceProvider::class,
],
```

Run Artisan command to publish vendor config file in rootproject/config/laraflake.php

```
$ php artisan vendor:publish --provider="Hafael\LaraFlake\LaraFlakeServiceProvider"
```

Import the ***LaraFlakeTrait*** in your model and set **$incrementing** to false:

```
class User extends Authenticatable
{
    use LaraFlakeTrait;
    protected $table = "users";

    /**
     * Indicates if the IDs are auto-incrementing.
     * @var bool
     */
    public $incrementing = false;
    ...
```

And update the migration files to use ***BIGINT(20) UNSIGNED***:

```
class CreateUsersTable extends Migration
{
    /**
     * Run the migrations.
     * @return void
     */
    public function up()
    {
        Schema::create('users', function (Blueprint $table) {

            $table->bigInteger('id')->unsigned()->primary();

            $table->string('name');
            $table->string('email')->unique();
            $table->string('password');
            $table->rememberToken();
            $table->timestamps();
        });
    }
    ...
```

### Development

[](#development)

Want to contribute? Great! Just create a pull request.

### Todos

[](#todos)

- Write Tests
- Write Benchmark Tests
- Implement support for other databases

License
-------

[](#license)

Apache 2.0

Inspiration
-----------

[](#inspiration)

Inspired on simplicity from [Particle by Silviu Schiau](https://github.com/sschiau/Particle.php%22).

- [Unique ID generation in distributed systems](http://pt.slideshare.net/davegardnerisme/unique-id-generation-in-distributed-systems)
- [Sharding &amp; IDs at Instagram](http://instagram-engineering.tumblr.com/post/10853187575/sharding-ids-at-instagram)
- [Twitter IDs](https://dev.twitter.com/overview/api/twitter-ids-json-and-snowflake)

###  Health Score

40

—

FairBetter than 87% of packages

Maintenance30

Infrequent updates — may be unmaintained

Popularity34

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 82.8% 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 ~125 days

Recently: every ~152 days

Total

10

Last Release

2452d ago

Major Versions

v0.2-alpha → v1.0.02016-10-05

### Community

Maintainers

![](https://www.gravatar.com/avatar/39ad3b7c146b7ff339338b2a19ff424f1d677a9ade97faa89f8d8eb19f1439cb?d=identicon)[hafael](/maintainers/hafael)

---

Top Contributors

[![hafael](https://avatars.githubusercontent.com/u/571130?v=4)](https://github.com/hafael "hafael (24 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (3 commits)")[![dimzeta](https://avatars.githubusercontent.com/u/3192298?v=4)](https://github.com/dimzeta "dimzeta (1 commits)")[![pararang](https://avatars.githubusercontent.com/u/8720184?v=4)](https://github.com/pararang "pararang (1 commits)")

---

Tags

laravelidsnowflake64bitshard

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/hafael-laraflake/health.svg)

```
[![Health](https://phpackages.com/badges/hafael-laraflake/health.svg)](https://phpackages.com/packages/hafael-laraflake)
```

###  Alternatives

[barryvdh/laravel-ide-helper

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

14.9k123.0M683](/packages/barryvdh-laravel-ide-helper)[kra8/laravel-snowflake

Snowflake for Laravel and Lumen.

188402.3k6](/packages/kra8-laravel-snowflake)[cybercog/laravel-optimus

An Optimus bridge for Laravel. Id obfuscation based on Knuth's multiplicative hashing method.

192564.1k](/packages/cybercog-laravel-optimus)[interaction-design-foundation/laravel-geoip

Support for multiple Geographical Location services.

17221.0k3](/packages/interaction-design-foundation-laravel-geoip)[nedwors/navigator

A Laravel package to ease defining navigation menus

433.1k](/packages/nedwors-navigator)[dcblogdev/laravel-junie

Install pre-configured guides for Jetbrains Junie

392.5k](/packages/dcblogdev-laravel-junie)

PHPackages © 2026

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