PHPackages                             eluhr/yii2-uuid-attribute-behavior - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. eluhr/yii2-uuid-attribute-behavior

ActiveYii2-extension[Utility &amp; Helpers](/categories/utility)

eluhr/yii2-uuid-attribute-behavior
==================================

This behavior automatically generates a UUID for the given attribute on create.

1.0.0(2y ago)18.0k—5%1BSD-3-ClausePHPPHP &gt;=7.4

Since Jan 22Pushed 2y ago1 watchersCompare

[ Source](https://github.com/eluhr/yii2-uuid-attribute-behavior)[ Packagist](https://packagist.org/packages/eluhr/yii2-uuid-attribute-behavior)[ RSS](/packages/eluhr-yii2-uuid-attribute-behavior/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (3)Versions (2)Used By (0)

Yii2 JSON Attribute Behavior
============================

[](#yii2-json-attribute-behavior)

This behavior automatically generates a UUID for the given attribute on create.

[![CI Workflow](https://github.com/eluhr/yii2-uuid-attribute-behavior/actions/workflows/ci.yml/badge.svg)](https://github.com/eluhr/yii2-uuid-attribute-behavior/actions/workflows/ci.yml/badge.svg)

Installation
------------

[](#installation)

The preferred way to install this extension is through [composer](https://getcomposer.org/download/).

Either run

```
composer require --prefer-dist eluhr/yii2-uuid-attribute-behavior "*"

```

or add

```
"eluhr/yii2-uuid-attribute-behavior": "*"

```

to the `require` section of your `composer.json` file.

Usage
-----

[](#usage)

In a `yii\base\Model` or a derivation thereof, the behavior can be used as follows:

```
public function behaviors(): array
{
    $behaviors = parent::behaviors();
    $behaviors['uuid-attribute'] = [
        'class' => eluhr\uuidAttributeBehavior\UuidAttributeBehavior::class
    ];
    return $behaviors;
}
```

By using this behavior it does not matter if the attribute is a string or an array. The behavior will always ensure, that the attribute is an array before saving the data to the database and yii will handle the rest.

This behavior supports [i18n](https://www.yiiframework.com/doc/guide/2.0/en/tutorial-i18n). By adding the `uuid-attribute-validator` category in your config you can overwrite the default error messages.

Testing
-------

[](#testing)

After installing dependencies via composer you can run the tests with:

```
make test
```

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity26

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

847d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/07b2ebef20cf3f8b95894ff50fdb0ba46cf04c8d74ffbb6a4e724af8569a8aec?d=identicon)[eluhr](/maintainers/eluhr)

---

Top Contributors

[![eluhr](https://avatars.githubusercontent.com/u/13000805?v=4)](https://github.com/eluhr "eluhr (3 commits)")

---

Tags

uuidyii2extensionBehavior

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/eluhr-yii2-uuid-attribute-behavior/health.svg)

```
[![Health](https://phpackages.com/badges/eluhr-yii2-uuid-attribute-behavior/health.svg)](https://phpackages.com/packages/eluhr-yii2-uuid-attribute-behavior)
```

###  Alternatives

[thamtech/yii2-uuid

Yii 2 UUID Helper

35347.9k7](/packages/thamtech-yii2-uuid)[sjaakp/yii2-taggable

Manage tags of ActiveRecord in Yii2.

3030.6k](/packages/sjaakp-yii2-taggable)[mdmsoft/yii2-autonumber

Auto number extension for the Yii framework

1830.9k](/packages/mdmsoft-yii2-autonumber)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
