qh-8/laravel-snowflake 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

qh-8/laravel-snowflake

最新稳定版本:v1.1.2

Composer 安装命令:

composer require qh-8/laravel-snowflake

包简介

Generate Snowflake Identifier for Laravel

README 文档

README

Latest Version on Packagist Total Downloads GitHub Actions

A Laravel package to generate unique snowflake ids.

Forked from kra8/laravel-snowflake.

Requirements

  • Laravel 10 or higher

Installation

composer require qh-8/laravel-snowflake

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

composer test

Changelog

Please see CHANGELOG for more information what has changed recently.

Security

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

Credits

License

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

统计信息

  • 总下载量: 181
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 6
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 6
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-09-16