horat1us / yii2-uuid-behavior
Yii2 UUID generation behavior
1.3.0
2026-10-25 19:24 UTC
Requires
- php: >=8.4
- ramsey/uuid: ^4.7
- yiisoft/yii2: ^2.0.53
Requires (Dev)
- horat1us/yii2-asset-free: ^1.0.1
- phpunit/phpunit: ^13.4
- squizlabs/php_codesniffer: ^4.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-10-25 19:34:34 UTC
README
Behavior to generate UUID values (mostly, for ActiveRecord primary key).
Compatibility: tested on PHP 8.4, PHP 8.5
Installation
Using packagist.org:
composer require horat1us/yii2-uuid-behavior:^1.0
Usage
To generate UUID for primary key follow example:
<?php namespace App; use Horat1us\Yii\UuidBehavior; use yii\db; /** * Class Record * @package App * * @property string $uuid // primary key in database, without default value and auto-increment */ class Record extends db\ActiveRecord { public function behaviors(): array { return [ 'uuid' => [ 'class' => UuidBehavior::class, ], ]; } }
in followed example uuid in active record will be filled with random UUIDv4 before inserting.