Download the PHP package bestyii/yii2-snowflake without Composer

On this page you can find all versions of the php package bestyii/yii2-snowflake. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package yii2-snowflake

YII2 Snowflake 雪花算法ID生成器

雪花算法ID生成器 (Yii2 组件)

Latest Stable Version Total Downloads License

环境要求

PHP >= 7.0

安装

安装此扩展的首选方法是:composer.

项目根目录下运行

或添加到composer.json文件的require区域中.

配置

快速上手

在配置文件中加入

参数 说明
startDate 起始日期 , 字符串Y-m-d格式, 如: '2022-12-31'

高级配置

雪花算法生成的 ID 并不能保证唯一,如当两个不同请求同一时刻进入相同的数据中心的相同节点时,而此时该节点生成的 sequence 又是相同时,就会导致生成的 ID 重复。 所以要想使用雪花算法生成唯一的 ID,就需要保证同一节点同一毫秒内生成的序列号是唯一的。

此扩展内置了基于redis的序列号生成器\bestyii\snowflake\RedisSequenceResolver,保证同一毫秒生成的序列号不同。

参数 说明
startDate 起始日期
datacenterId 数据中心id
workerId 主机id
sequencer \bestyii\snowflake\RedisSequenceResolver, 需要配置 yii2-redis 组件

如何使用

手动

生成id

解析id

使用Behavior自动生成id

本组件支持通过附加ActiveRecord Model的behavior方式来完成自动生成id

使用下列语法:

在数据保存之前, 该behavior(行为)会自动生成id.

雪花算法说明

本项目基于 godruoyi/php-snowflake 实现.

Snowflake 是 Twitter 内部的一个 ID 生算法,可以通过一些简单的规则保证在大规模分布式情况下生成唯一的 ID 号码。其组成为:

需要注意的是:


All versions of yii2-snowflake with dependencies

PHP Build Version
Package Version
Requires yiisoft/yii2 Version ^2.0.0
godruoyi/php-snowflake Version ^2.0.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package bestyii/yii2-snowflake contains the following files

Loading the files please wait ....