wartron/yii2-uuid 问题修复 & 功能扩展

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

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

wartron/yii2-uuid

Composer 安装命令:

composer require wartron/yii2-uuid

包简介

Yii2 UUID Helpers

README 文档

README

Helpers for using uuids as primary keys.

Installation

Add the uuid behavior to models.

We could use the SqlExpression to generate the uuid in sql, but we dont get the ID back in last insert id. (We can get around this with triggers if you want a pure SQL method). But generating the ID UUID in php we dont need to worry about getting the id an refreshing the model.

Using our UUID'd ActiveRecord, it will take care of generating the id, and can handle toArray for api calls repersenting the uuid and other uuid fields as in hex.

use wartron\yii2uuid\db\ActiveRecord;

Using the Behavior for id.

public function behaviors()
{
    return [
        \wartron\yii2uuid\behaviors\UUIDBehavior::className(),
    ];
}

To use the formater asHex

'components' => [
    'formatter' => [
        'class' => '\wartron\yii2uuid\components\Formatter'
    ],
]

The Helper providers access to ramsey/uuid. This will automaticly convert to the binary from we use!

use wartron\yii2uuid\helpers\Uuid;

//generate uuids
Uuid::uuid1();
Uuid::uuid3();
Uuid::uuid4();
Uuid::uuid5();

//converting
Uuid::str2uuid($hexString);
Uuid::uuid2str($binary);

To use the rest ActiveControllers use the provided ActiveController instead of yii\rest\ActiveController

use wartron\yii2uuid\rest\ActiveController;

统计信息

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

GitHub 信息

  • Stars: 9
  • Watchers: 1
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-08-20

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固