2017 © Pedro Peláez
 

yii2-extension phpuser

Simple non-database user class for yii2 projects

image

vkabachenko/phpuser

Simple non-database user class for yii2 projects

  • Friday, April 15, 2016
  • by vkabachenko
  • Repository
  • 1 Watchers
  • 0 Stars
  • 33 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 136 % Grown

The README.md

OVERVIEW

This extension provides user model based on user information gathered in configuration file instead of traditional database table. It may be useful in the case of one or few users in web application., (*1)

INSTALLATION

Either run, (*2)

php composer.phar require vkabachenko/phpuser "dev-master"

or add, (*3)

"vkabachenko/phpuser": "dev-master"

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

SETUP

Prepare your console controller, say UserController as follows:, (*5)

class UserController extends \yii\console\Controller
{

    public function actions()
    {
        return [
            'add' => [
                'class' => 'vkabachenko\phpuser\AddUserAction',
                'pathAlias' => '@common'
            ],
        ];
    }
}

Property pathAlias depends on where user configuration file would be. In that case in @common/config/users.php., (*6)

Run the controller's action in console, (*7)

Run, (*8)

php yii user/add

and enter username and password for the user. Appropriate data would be stored in configuration file users.php., (*9)

Merge user's data as application parameter, (*10)

Merge users.php file with other parameters files. For example in @common/config/main.php, (*11)

$params = array_merge(
    require(__DIR__ . '/params.php'),
    require(__DIR__ . '/params-local.php'),
...........................................,
    require(__DIR__ . '/users.php')
);

Use class vkabachenko\phpuser\User.php in application, (*12)

Now you can use model vkabachenko\phpuser\User.php for identifying user throughout the application: in identityClass at the components/user config section, in login action and so on., (*13)

The Versions

15/04 2016

dev-master

9999999-dev https://github.com/vkabachenko/phpuser

Simple non-database user class for yii2 projects

  Sources   Download

MIT

The Requires

 

by Viktor Kabachenko

user yii2 model