2017 © Pedro Peláez
 

library laraflake

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

image

hafael/laraflake

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

  • Friday, December 22, 2017
  • by hafael
  • Repository
  • 1 Watchers
  • 11 Stars
  • 1,109 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 3 Forks
  • 0 Open issues
  • 8 Versions
  • 17 % Grown

The README.md

, (*1)

# LaraFlake

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

  • 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..., (*3)

How to use

Run the composer require command from your terminal:, (*4)

$ composer require hafael/laraflake

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

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

Run Artisan command to publish vendor config file in rootproject/config/laraflake.php, (*6)

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

Import the LaraFlakeTrait in your model and set $incrementing to false:, (*7)

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:, (*8)

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

Want to contribute? Great! Just create a pull request., (*9)

Todos

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

License

Apache 2.0, (*10)

Inspiration

Inspired on simplicity from Particle by Silviu Schiau., (*11)

The Versions

22/12 2017

dev-master

9999999-dev

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

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

by Rafael Villa-Verde

laravel id 64bit shard snowflake

22/12 2017

v1.2.2

1.2.2.0

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

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

by Rafael Villa-Verde

laravel id 64bit shard snowflake

19/12 2017

v1.2.1

1.2.1.0

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

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

by Rafael Villa-Verde

laravel id 64bit shard snowflake

16/12 2017

v1.2.0

1.2.0.0

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

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

by Rafael Villa-Verde

laravel id 64bit shard snowflake

02/06 2017

v1.1.0

1.1.0.0

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

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

by Rafael Villa-Verde

laravel id 64bit shard snowflake

05/10 2016

v1.0.0

1.0.0.0

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

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

by Rafael Villa-Verde

laravel id 64bit shard snowflake

19/08 2016

v0.2-alpha

0.2.0.0-alpha

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

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

by Rafael Villa-Verde

laravel id 64bit shard snowflake

22/07 2016

v0.1.0

0.1.0.0

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

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

by Rafael Villa-Verde

laravel id 64bit shard snowflake