2017 © Pedro Peláez
 

yii2-extension yii2-scalable-behavior

Key-Value storage is a very simplistic, but very powerful model. Use this behavior to expand your Yii 2 model without changing the structure.

image

cakebake/yii2-scalable-behavior

Key-Value storage is a very simplistic, but very powerful model. Use this behavior to expand your Yii 2 model without changing the structure.

  • Tuesday, September 9, 2014
  • by cakebake
  • Repository
  • 2 Watchers
  • 3 Stars
  • 84 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 2 Versions
  • 9 % Grown

The README.md

Scalable Database Schema

Key-Value storage is a very simplistic, but very powerful model. Use this behavior to expand your Yii 2 model without changing the structure., (*1)

Data can be queried and saved with "virtual attributes". These are stored serialized in a configured table column., (*2)

Installation

The preferred way to install this extension is through composer., (*3)

Either run, (*4)

php composer.phar require --prefer-dist cakebake/yii2-scalable-behavior "*"

or add, (*5)

"cakebake/yii2-scalable-behavior": "*"

to the require section of your composer.json file., (*6)

Preparation

Create a column in your desired table. It is recommended to use the type "text" or "longtext" in order to save as much data as possible., (*7)

Usage

Once the extension is installed, simply use it in your model by adding:, (*8)

    use cakebake\behaviors\ScalableBehavior;

    public function behaviors()
    {
        return [
            ...
            'scaleable' => [
                'class' => ScalableBehavior::className(),
                'scalableAttribute' => 'value', // The owner object's attribute / the column of the corresponding table, which are used as storage for the virtual attributes
                'virtualAttributes' => ['about_me', 'birthday'] // Definition of virtual attributes that are added to the owner object
            ],
            ...
        ];
    }

Now we can proceed similarly with the virtual attributes like normal., (*9)

    public function rules()
    {
        return [
            ['about_me', 'required'],
            ['about_me', 'string'],
            ['birthday', 'string', 'max' => 60],
        ];
    }

Piece of advice

This technique should be used only for metadata. Improper use may change the application performance negatively., (*10)

The Versions

09/09 2014

dev-master

9999999-dev

Key-Value storage is a very simplistic, but very powerful model. Use this behavior to expand your Yii 2 model without changing the structure.

  Sources   Download

LGPL-V3

by cakebake (Jens A.)

database schema extension yii2 behavior mysql activerecord data db serialize convert unserialize attributes virtual dynamic scalable

09/09 2014

1.0.0-beta

1.0.0.0-beta

Key-Value storage is a very simplistic, but very powerful model. Use this behavior to expand your Yii 2 model without changing the structure.

  Sources   Download

LGPL-V3

by cakebake (Jens A.)

database schema extension yii2 behavior mysql activerecord data db serialize convert unserialize attributes virtual dynamic scalable