Snowflake is a package for Laravel that allows Twitter's 64 bit snowflake to be used as primary identifier for models.
- Keys begin with a timestamp
- Keys end with a random number, so guessing the size of the table is impossible
- Keys consist entirely of integers, which are handled more efficiently than strings
- Faster key generation (<1ms)
- Standard UUID v4 - 5.6 milliseconds
- Sortable UUID v4 - 8.3 milliseconds
- ULID - 3.1 milliseconds
- Snowflake - 0.4 milliseconds
composer require jakyeru/snowflake
resolve('snowflake')->id(); // ---> 112871594573041664
<?php
namespace App\Models;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Jakyeru\Snowflake\Traits\HasSnowflakes;
class User extends Authenticatable
{
use HasSnowflakes;
}
php artisan vendor:publish --tag=snowflake-config
Thank you for considering contributing to Snowflake! You can read the contribution guide here.
In order to ensure that the community is welcoming to everyone, please review and abide by the Code of Conduct.
If you need to report a security vulnerability please read our Security Policy.
snowflake is open-sourced software licensed under the MIT license.
If you encounter any other error(s), please open an issue on GitHub.