Download the PHP package laith-zraikat/yii2-uuid-behavior without Composer
On this page you can find all versions of the php package laith-zraikat/yii2-uuid-behavior. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Table of contents
Download laith-zraikat/yii2-uuid-behavior
More information about laith-zraikat/yii2-uuid-behavior
Files in laith-zraikat/yii2-uuid-behavior
Download laith-zraikat/yii2-uuid-behavior
More information about laith-zraikat/yii2-uuid-behavior
Files in laith-zraikat/yii2-uuid-behavior
Vendor laith-zraikat
Package yii2-uuid-behavior
Short Description Yii2 behavior for automatically generating and formatting UUIDs for ActiveRecord models
License MIT
Package yii2-uuid-behavior
Short Description Yii2 behavior for automatically generating and formatting UUIDs for ActiveRecord models
License MIT
Please rate this library. Is it a good library?
Informations about the package yii2-uuid-behavior
Yii2 UUID Behavior
A Yii2 behavior for automatically generating and formatting UUIDs for ActiveRecord models.
Features
- Automatically generates UUIDs for new records
- Supports both PHP-generated and MySQL-generated UUIDs
- Configurable UUID format (with or without dashes)
- Handles existing UUIDs and ensures proper formatting
- Optional UUID generation on record updates
Installation
The preferred way to install this extension is through composer.
Usage
Attach the behavior to your ActiveRecord model:
Configuration Options
Option | Type | Default | Description |
---|---|---|---|
attribute |
string | 'uuid' |
The model attribute that will store the UUID |
method |
string | UUIDBehavior::METHOD_MYSQL |
UUID generation method (METHOD_MYSQL or METHOD_PHP ) |
keepDashes |
boolean | true |
Whether to keep dashes in the UUID |
enableOnUpdate |
boolean | false |
Whether to generate UUID on model update |
UUID Generation Methods
MySQL Method (METHOD_MYSQL
)
Uses MySQL's UUID()
function to generate UUIDs. This method:
- Has better performance and uniqueness guarantees
- Requires a database call to generate the UUID
- The UUID is only available after the record is saved
PHP Method (METHOD_PHP
)
Generates UUIDs using PHP's mt_rand()
function. This method:
- Makes the UUID available before saving the record
- Works with any database backend
- Slightly less performant than the MySQL method
UUID Formatting
The behavior supports two UUID formats:
- Standard format (with dashes):
xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
- Compact format (without dashes):
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Use the keepDashes
option to control the format.
License
This project is licensed under the MIT License - see the LICENSE file for details.
All versions of yii2-uuid-behavior with dependencies
PHP Build Version
Package Version
The package laith-zraikat/yii2-uuid-behavior contains the following files
Loading the files please wait ....