PHPackages                             iachilles/eavactiverecord - 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. iachilles/eavactiverecord

ActiveYii-extension[Database &amp; ORM](/categories/database)

iachilles/eavactiverecord
=========================

Implements entity-attribute-value pattern and provides a simple way to work with EAV-attributes.

1.0.4(11y ago)9346MITPHPPHP &gt;=5.1.0

Since Sep 26Pushed 11y ago1 watchersCompare

[ Source](https://github.com/iAchilles/eavactiverecord)[ Packagist](https://packagist.org/packages/iachilles/eavactiverecord)[ Docs](https://github.com/iAchilles/eavactiverecord)[ RSS](/packages/iachilles-eavactiverecord/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (5)DependenciesVersions (6)Used By (0)

EavActiveRecord
===============

[](#eavactiverecord)

Implements entity-attribute-value pattern and provides a simple way to work with EAV-attributes. EAV-attributes are stored in the database as separate records but accessed and searched in such a way as if they were columns in the entity's table.

The following features are supported:

- Eager and lazy loading of EAV-attributes.
- Dynamic validation rules. The validation rules defined for the EAV-attribute will be added to the model dynamically.
- Automatically inserting/updating/deleting EAV-attribute values.
- Accessing and editing EAV-attributes in the same way as if they were real attributes of the model.
- A simple search by EAV-attributes with using the find methods.

Requirements
------------

[](#requirements)

- Yii 1.1.2 or above
- PHP 5.1 or above

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

[](#installation)

1. Download and extract the release files under the folder "protected/components/eavactiverecord".
2. Run the SQL-script mysql.sql or postgresql.sql (if your DBMS is PostgreSQL) It is located in the following folder: "protected/components/eavactiverecord/schema/". It creates tables needed to work with EAV attributes: eav\_set, eav\_attribute, eav\_attribute\_set, eav\_attribute\_date, eav\_attribute\_int, eav\_attribute\_varchar, eav\_attribute\_text.
3. Add the following lines in the file "protected/config/main.php":

    ```
    ```

array( 'import' =&gt; array( 'application.components.eavactiverecord.*', 'application.components.eavactiverecord.datatypes.*', 'application.components.eavactiverecord.helpers.\*' )

```

1. It requires cache to be activated in the application:

   ```php
array(
    …
    'components'=>array(
        …
        'cache'=>array(
            'class'=>'system.caching.CMemCache',
            'servers'=>array(
                array('host'=>'server1', 'port'=>11211, 'weight'=>60),
                array('host'=>'server2', 'port'=>11211, 'weight'=>40),
            ),
        ),
    ),
);

```

The extension will use own cache component if it is defined as the following:

```
array(
 …
 'components'=>array(
     …
     'eavCache'=>array(
         'class'=>'system.caching.CMemCache',
         'servers'=>array(
             array('host'=>'server1', 'port'=>11211, 'weight'=>60),
             array('host'=>'server2', 'port'=>11211, 'weight'=>40),
         ),
     ),
 ),
);
```

If you do not use cache, add the following code in the file "protected/config/main.php":

```
'components' => array(
     'eavCache' => array(
         'class' => 'system.caching.CDummyCache'
     ),
  )
```

1. Extend your model class from the class EavActiveRecord

    ```
    ```

class Foo extends EavActiveRecord

```

1. Call the method Foo::addColumn(). This method must only be called once for each model that extends EavActiveRecord class.
It adds the new column "eav_set_id" in the associated database table.

   ```php
Foo::model()->addColumn();

```

1. Since v1.0.2 it includes the GUI module for user interaction (front-end module) based on the extension API. For detailed information about installing the module, reed the [EavModule Installation Guide](https://github.com/iAchilles/eavactiverecord/wiki/EavModule-Installation-Guide)

    *The screenshot of the module page is shown below*[![EavModule screenshot](https://camo.githubusercontent.com/71478d87676a101f5b374a918013aaa33fa46d014ec73ce222fa893c953c61d7/68747470733a2f2f646f63732e676f6f676c652e636f6d2f75633f6578706f72743d646f776e6c6f61642669643d304233643369585379434254696132686e5455564e4d6b6b77643055)](https://camo.githubusercontent.com/71478d87676a101f5b374a918013aaa33fa46d014ec73ce222fa893c953c61d7/68747470733a2f2f646f63732e676f6f676c652e636f6d2f75633f6578706f72743d646f776e6c6f61642669643d304233643369585379434254696132686e5455564e4d6b6b77643055)

\##What's next?

For detailed information on how to use the extension eavactiverecord, please read the following wiki articles:

1. [Quick Start Guide](https://github.com/iAchilles/eavactiverecord/wiki/Quick-Start-Guide)
2. [Manage EAV attributes](https://github.com/iAchilles/eavactiverecord/wiki/Manage-EAV-attributes)
3. [Manage sets of EAV attributes](https://github.com/iAchilles/eavactiverecord/wiki/Manage-sets-of-EAV-attributes)
4. [Using EAV attributes in the model](https://github.com/iAchilles/eavactiverecord/wiki/Using-EAV-attributes-in-the-model)
    1. [Attaching EAV attributes to the model](https://github.com/iAchilles/eavactiverecord/wiki/Using-EAV-attributes-in-the-model#i)
    2. [Assigning a value to the EAV attribute](https://github.com/iAchilles/eavactiverecord/wiki/Using-EAV-attributes-in-the-model#ii)
    3. [Accessing the EAV attribute value](https://github.com/iAchilles/eavactiverecord/wiki/Using-EAV-attributes-in-the-model#iii)
    4. [Saving the EAV attribute value](https://github.com/iAchilles/eavactiverecord/wiki/Using-EAV-attributes-in-the-model#iv)
    5. [Deleting the EAV attribute value](https://github.com/iAchilles/eavactiverecord/wiki/Using-EAV-attributes-in-the-model#v)
    6. [Eager and lazy loading of EAV attribute values](https://github.com/iAchilles/eavactiverecord/wiki/Using-EAV-attributes-in-the-model#vi)
    7. [Searching by EAV attributes](https://github.com/iAchilles/eavactiverecord/wiki/Using-EAV-attributes-in-the-model#vii)
    8. [Priority of attributes](https://github.com/iAchilles/eavactiverecord/wiki/Using-EAV-attributes-in-the-model#viii)
5. [Creating form elements for EAV attributes using the widget EavForm](https://github.com/iAchilles/eavactiverecord/wiki/Creating-form-elements-for-EAV-attributes-using-the-widget-EavForm)
6. [The API documentation](https://github.com/iAchilles/eavactiverecord/wiki/The-API-documentation)

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity62

Established project with proven stability

 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

Every ~13 days

Total

5

Last Release

4196d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/0d0a961fba403ba6057b2428d01dcdefb6dc106809331673629d60155b5d50b7?d=identicon)[iAchilles](/maintainers/iAchilles)

---

Top Contributors

[![iAchilles](https://avatars.githubusercontent.com/u/3855716?v=4)](https://github.com/iAchilles "iAchilles (52 commits)")

---

Tags

extensionyiiactiverecordeavobject-attribute-value

### Embed Badge

![Health badge](/badges/iachilles-eavactiverecord/health.svg)

```
[![Health](https://phpackages.com/badges/iachilles-eavactiverecord/health.svg)](https://phpackages.com/packages/iachilles-eavactiverecord)
```

###  Alternatives

[yiiext/activerecord-relation-behavior

Inspired by and put together the awesomeness of many yii extensions that aim to improve saving of related records. Comes with 100% test coverage and well structured and clean code so it can savely be used in enterprise production enviroment.

9336.5k](/packages/yiiext-activerecord-relation-behavior)[yiiext/migrate-command

This is an enhanced version of the Yii Database Migration Tool that adds module support and many more usefull features.

34173.8k4](/packages/yiiext-migrate-command)[sjaakp/yii2-sortable-behavior

Sort ActiveRecords and related records in Yii2.

36144.7k](/packages/sjaakp-yii2-sortable-behavior)[sjaakp/yii2-spatial

Yii2 ActiveRecord supporting MySQL spatial data

1873.8k1](/packages/sjaakp-yii2-spatial)[nanson/yii2-postgis

Yii2-extension to work with postgis data

1851.6k](/packages/nanson-yii2-postgis)[mg-code/yii2-helpers

A collection of useful helper classes for Yii framework 2.0

2022.5k5](/packages/mg-code-yii2-helpers)

PHPackages © 2026

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