xutl / yii2-snowflake
The snowflake extension for the Yii framework
Installs: 27 320
Dependents: 0
Suggesters: 0
Security: 0
Stars: 7
Watchers: 1
Forks: 3
Open Issues: 2
Type:yii2-extension
Requires
- php: >=5.4.0
- yiisoft/yii2: ~2.0.0
This package is auto-updated.
Last update: 2024-11-11 02:47:19 UTC
README
适用于 Yii2 的 雪花算法ID生成器。Based on the Twitter Snowflake algorithm.
Installation
Next steps will guide you through the process of installing using composer. Installation is a quick and easy three-step process.
Step 1: Install component via composer
Either run
composer require --prefer-dist xutl/yii2-snowflake
or add
"xutl/yii2-snowflake": "~1.0.0"
to the require
section of your composer.json.
Step 2: Configuring your application
Add following lines to your main configuration file:
'components' => [ 'snowflake' => [ 'class' => 'xutl\snowflake\Snowflake', 'workerId' => 0, 'dataCenterId' => 0, ], ],
Step 3: Configuring your Model Behavior
/** * @inheritdoc */ public function behaviors() { return [ 'snowflake'=>[ 'class' => 'xutl\snowflake\SnowflakeBehavior', 'attribute' => 'id', ], ]; }
License
This is released under the MIT License. See the bundled LICENSE.md for details.