2017 © Pedro Peláez
 

yii2-extension yii2-user-profile

Yii2 user profile

image

sersid/yii2-user-profile

Yii2 user profile

  • Tuesday, March 17, 2015
  • by Sersid
  • Repository
  • 1 Watchers
  • 0 Stars
  • 62 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 2 % Grown

The README.md

Yii2 User Profile

Manage configuration from database, (*1)

Installation

One

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

Either run, (*3)

php composer.phar require --prefer-dist sersid/yii2-user-profile "dev-master"

or add, (*4)

"sersid/yii2-user-profile": "dev-master"

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

Two

Applying migrations, (*6)

yii migrate --migrationPath=@vendor/sersid/yii2-user-profile/migrations

Three

$config = [
    ...
    'components' => [
        ...
        'profile' => [
            'class' => 'sersid\profile\components\Profile',
        ],
    ]
];

Usage

Once the extension is installed, simply use it in your code by :, (*7)

Set

Yii::$app->profile->set('foo', 'bar');
Yii::$app->profile->set(['foo' => 'bar']);

Get

Yii::$app->profile->get('foo'); // bar

Model

Yii::$app->profile->model(); // sersid\profile\models\Model

Create fields

One

Create migration, (*8)

yii migrate/create profile_fields
use yii\db\Schema;
use yii\db\Migration;
class m150317_155953_profile_fields extends Migration
{
    public function up()
    {
        $this->addColumn('{{%profile}}', 'lang', Schema::TYPE_STRING);
        // ... your fields
    }
    public function down()
    {
        $this->dropColumn('{{%profile}}', 'lang');
        // ... your fields
    }
}

Two

Update model, (*9)

namespace app\models;
use sersid\profile\models\Model;
class Profile extends Model
{
    const LANG_EN = 'en';
    const LANG_RU = 'ru';
    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            ['lang', 'default', 'value' => self::LANG_EN],
            ['lang', 'in', 'range' => [self::LANG_EN, self::LANG_RU]],
            // ... your rules
        ];
    }
}

Three

$config = [
    ...
    'components' => [
        ...
        'profile' => [
            'class' => 'sersid\profile\components\Profile',
            'model' => 'app\models\Profile',
        ],
    ]
];

Uninstall

Applying migrations, (*10)

yii migrate/down --migrationPath=@vendor/sersid/yii2-user-profile/migrations

The Versions

17/03 2015

dev-master

9999999-dev

Yii2 user profile

  Sources   Download

BSD-3-Clause

The Requires

 

by Avatar Sersid

profile extension yii2