PHPackages                             urmaul/yii-enumattributes - 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. [Database &amp; ORM](/categories/database)
4. /
5. urmaul/yii-enumattributes

ActiveLibrary[Database &amp; ORM](/categories/database)

urmaul/yii-enumattributes
=========================

Yii ActiveRecord behavior used to work with ENUM attributes.

0501PHP

Since Jun 18Pushed 11y agoCompare

[ Source](https://github.com/urmaul/yii-enumattributes)[ Packagist](https://packagist.org/packages/urmaul/yii-enumattributes)[ RSS](/packages/urmaul-yii-enumattributes/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Yii Enumattributes
==================

[](#yii-enumattributes)

Yii ActiveRecord behavior used to work with ENUM attributes

Installing
----------

[](#installing)

```
composer require urmaul/yii-enumattributes dev-master

```

Attaching example
-----------------

[](#attaching-example)

You need to add this behavior to behaviors:

```
public function behaviors()
{
    return array(
        ...
        'statusEnum' => array(
            'class' => 'EnumAttributesBehavior',
            'attribute' => 'status',
        ),
    );
}
```

### Options

[](#options)

- attribute (string) - enum attribute name
- labels (array) - custom labels array (value =&gt; label)

### Class phpDoc

[](#class-phpdoc)

And also you should add behavior property to phpDoc comments:

```
/**
 * ...
 *
 * @property EnumAttributesBehavior $statusEnum
 */
class ...
```

Using
-----

[](#using)

### Values

[](#values)

Now you can retrieve list of possible values by calling behavior like that:

```
$model->statusEnum->values
```

Values order is equal to values order in DB structure.

### Labels

[](#labels)

Or you can retrieve a map "value =&gt; label" by calling behavior like that:

```
$model->statusEnum->valueLabels
```

Values order is equal to values order in DB structure.

Labels are generated from values using [CModel::generateAttributeLabel](http://www.yiiframework.com/doc/api/1.1/CModel#generateAttributeLabel-detail) function. You can set custom labels using the **labels** behavior option.

### Validation rule

[](#validation-rule)

This behavior can generate validation rule for you.

```
public function rules()
{
    return array(
        ...
        $this->statusEnum->rule,
        // or
        $this->statusEnum->rule + array('on' => 'create'),
        ...
    );
}
```

###  Health Score

21

—

LowBetter than 19% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/22364b943477de78bf89bb19b5708a93666e38b5f1ad954ded9c656b3c116cb8?d=identicon)[urmaul](/maintainers/urmaul)

### Embed Badge

![Health badge](/badges/urmaul-yii-enumattributes/health.svg)

```
[![Health](https://phpackages.com/badges/urmaul-yii-enumattributes/health.svg)](https://phpackages.com/packages/urmaul-yii-enumattributes)
```

###  Alternatives

[doctrine/orm

Object-Relational-Mapper for PHP

10.2k285.3M6.2k](/packages/doctrine-orm)[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k115.1M102](/packages/jdorn-sql-formatter)[illuminate/database

The Illuminate Database package.

2.8k52.4M9.3k](/packages/illuminate-database)[mongodb/mongodb

MongoDB driver library

1.6k64.0M542](/packages/mongodb-mongodb)[ramsey/uuid-doctrine

Use ramsey/uuid as a Doctrine field type.

90340.3M209](/packages/ramsey-uuid-doctrine)[reliese/laravel

Reliese Components for Laravel Framework code generation.

1.7k3.4M16](/packages/reliese-laravel)

PHPackages © 2026

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