PHPackages                             yiiext/eav-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. yiiext/eav-behavior

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

yiiext/eav-behavior
===================

yii entity attrbiute value behavior

02592PHP

Since Dec 7Pushed 12y ago1 watchersCompare

[ Source](https://github.com/fuoricentrostudio/eav-behavior)[ Packagist](https://packagist.org/packages/yiiext/eav-behavior)[ RSS](/packages/yiiext-eav-behavior/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

EAV behavior
============

[](#eav-behavior)

Allows model to work with custom fields on the fly (EAV pattern).

Installing and configuring
--------------------------

[](#installing-and-configuring)

### Create a table that will store EAV-attributes

[](#create-a-table-that-will-store-eav-attributes)

SQL dump:

```
[sql]
CREATE TABLE IF NOT EXISTS `eavAttr` (
  `entity` bigint(20) unsigned NOT NULL,
  `attribute` varchar(250) NOT NULL,
  `value` text NOT NULL,
  KEY `ikEntity` (`entity`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8;

```

### Attach behaviour to your model

[](#attach-behaviour-to-your-model)

```
[php]
function behaviors() {
    return array(
        'eavAttr' => array(
            'class' => 'ext.yiiext.behaviors.model.eav.EEavBehavior',
            // Table that stores attributes (required)
            'tableName' => 'eavAttr',
            // model id column
            // Default is 'entity'
            'entityField' => 'entity',
            // attribute name column
            // Default is 'attribute'
            'attributeField' => 'attribute',
            // attribute value column
            // Default is 'value'
            'valueField' => 'value',
            // Model FK name
            // By default taken from primaryKey
            'modelTableFk' => primaryKey,
            // Array of allowed attributes
            // All attributes are allowed if not specified
            // Empty by default
            'safeAttributes' => array(),
            // Attribute prefix. Useful when storing attributes for multiple models in a single table
            // Empty by default
            'attributesPrefix' => '',
        )
    );
}

```

Methods
-------

[](#methods)

### getEavAttributes($attributes)

[](#geteavattributesattributes)

Get attribute values indexed by attributes name.

```
[php]
$user = User::model()->findByPk(1);
$user->getEavAttributes(array('attribute1', 'attribute2'));

```

### getEavAttribute($attribute)

[](#geteavattributeattribute)

Get attribute value.

```
[php]
$user = User::model()->findByPk(1);
$user->getEavAttribute('attribute1');

```

### setEavAttribute($attribute, $value, $save = FALSE)

[](#seteavattributeattribute-value-save--false)

Set attribute value.

```
[php]
$user = User::model()->findByPk(1);
$user->setEavAttribute('attribute1', 'value1');

```

### setEavAttributes($attributes, $save = FALSE)

[](#seteavattributesattributes-save--false)

Set attributes values.

```
[php]
$user = User::model()->findByPk(1);
$user->setEavAttributes(array('attribute1' => 'value1', 'attribute2' => 'value2'));

```

### withEavAttributes($attributes)

[](#witheavattributesattributes)

Limits AR query to records with specified attributes.

```
[php]
$users = User::model()->withEavAttributes(array('skype'))->findAll();
$usersCount = User::model()->withEavAttributes(array('skype'))->count();

```

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor3

3 contributors hold 50%+ of commits

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/7a82a47436ceac89bbaeb95a8367354273e56082b8bbbaa8c50ababaf6032d77?d=identicon)[brandomeniconi](/maintainers/brandomeniconi)

---

Top Contributors

[![samdark](https://avatars.githubusercontent.com/u/47294?v=4)](https://github.com/samdark "samdark (2 commits)")[![brandomeniconi](https://avatars.githubusercontent.com/u/393114?v=4)](https://github.com/brandomeniconi "brandomeniconi (1 commits)")[![cebe](https://avatars.githubusercontent.com/u/189796?v=4)](https://github.com/cebe "cebe (1 commits)")[![creocoder](https://avatars.githubusercontent.com/u/896494?v=4)](https://github.com/creocoder "creocoder (1 commits)")[![mbischof](https://avatars.githubusercontent.com/u/1442526?v=4)](https://github.com/mbischof "mbischof (1 commits)")[![slavcodev](https://avatars.githubusercontent.com/u/757721?v=4)](https://github.com/slavcodev "slavcodev (1 commits)")

### Embed Badge

![Health badge](/badges/yiiext-eav-behavior/health.svg)

```
[![Health](https://phpackages.com/badges/yiiext-eav-behavior/health.svg)](https://phpackages.com/packages/yiiext-eav-behavior)
```

###  Alternatives

[zhelyabuzhsky/yii2-sitemap

A Yii2 tool to generate sitemap.xml.

3439.7k](/packages/zhelyabuzhsky-yii2-sitemap)[amplifier/yii-amqp

AMQP adapter for Yii

2237.0k](/packages/amplifier-yii-amqp)[bigfork/htmleditorsrcset

Simple srcset integration with SilverStripe’s HTMLEditorField

1025.4k4](/packages/bigfork-htmleditorsrcset)[anasstouaticoder/magento2-module-instantconfigurationcopy

The InstantConfigurationCopy module provides easy way to copy configuration field information for admin in back office Magento 2.

163.8k](/packages/anasstouaticoder-magento2-module-instantconfigurationcopy)

PHPackages © 2026

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