deesoft/yii2-tools

Yii2 application tools

Installs: 465

Dependents: 1

Suggesters: 0

Security: 0

Stars: 0

Watchers: 2

Forks: 0

Open Issues: 0

Type:yii2-extension

1.0 2016-04-26 08:48 UTC

This package is not auto-updated.

Last update: 2024-12-16 08:20:36 UTC


README

Yii2 Tools

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require deesoft/yii2-tools "~1.0"

or add

"deesoft/yii2-tools": "~1.0"

to the require section of your composer.json file.

AutoHandlerBehavior

Define event handler in self class.

class User extends ActiveRecord
{
    public function onBeforeSave($event)
    {
        // execute at event beforeSave
        // do someting
    }

    public function behaviors()
    {
        return [
            'dee\tools\AutoHandlerBehavior',
        ];
    }
}

State

Save information of client(browser).

// config
'components' => [
    ...
    'profile' => 'dee\tools\State',
]

Usage

// this information is unique per client.
Yii::$app->profile->address = 'Jl. Buntu No 3426 Lamongan';

echo Yii::$app->profile->address;