https://github.com/xutl/yii2-snowflake
The snowflake extension for the yii framework.
https://github.com/xutl/yii2-snowflake
snowflake yii2 yii2-extension
Last synced: about 1 month ago
JSON representation
The snowflake extension for the yii framework.
- Host: GitHub
- URL: https://github.com/xutl/yii2-snowflake
- Owner: xutl
- License: mit
- Created: 2017-10-23T03:26:07.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-11-06T06:00:34.000Z (over 7 years ago)
- Last Synced: 2024-09-29T23:01:29.455Z (8 months ago)
- Topics: snowflake, yii2, yii2-extension
- Language: PHP
- Homepage:
- Size: 7.81 KB
- Stars: 7
- Watchers: 1
- Forks: 3
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# yii2-snowflake
适用于 Yii2 的 雪花算法ID生成器。Based on the Twitter Snowflake algorithm.
[](https://packagist.org/packages/xutl/yii2-snowflake)
[](https://packagist.org/packages/xutl/yii2-snowflake)
[](https://www.versioneye.com/php/xutl:yii2-snowflake/references)
[](http://travis-ci.org/xutl/yii2-snowflake)
[](https://www.versioneye.com/php/xutl:yii2-snowflake/dev-master)
[](https://packagist.org/packages/xutl/yii2-snowflake)Installation
------------Next steps will guide you through the process of installing using [composer](http://getcomposer.org/download/). 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
```json
"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:
```php
'components' => [
'snowflake' => [
'class' => 'xutl\snowflake\Snowflake',
'workerId' => 0,
'dataCenterId' => 0,
],
],
```### Step 3: Configuring your Model Behavior
```php
/**
* @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](LICENSE.md)
for details.