定制 alexeyco/snowflake 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

alexeyco/snowflake

Composer 安装命令:

composer require alexeyco/snowflake

包简介

Generate Twitter Snowflake flavoured IDs

README 文档

README

Build Status Coverage Status StyleCI

Twitter Snowflake flavoured IDs:

  • Generate and parse it;
  • Convert it to string or integer value;
  • Enjoy that it's not UUID (a joke, who does not like UUID).

Generate

<?php

use SnowFlake\Node;

// Set up custom epoch and node
Node::getInstance()
    ->setEpoch(new \DateTime('2000-01-01 00:00:00')) // Default is 2006-03-21:20:50:14 GMT
    ->setNode(1); // Default is 0; can be between 0 and 1023

$id = Node::getInstance()->generate();

var_dump($id->toInt());
// => 6375898920270168065

var_dump($id->toString();
// => 1cfvnjc093zlt

Parse

<?php

use SnowFlake\Parser;

$id = Parser::fromString('1cfvnjc093zlt');

var_dump($id->toInt());
// ==> 6375898920270168065

License

MIT License

Copyright (c) 2018 Alexey Popov

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

统计信息

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

GitHub 信息

  • Stars: 5
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-03-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固