dev-master
9999999-dev https://github.com/vkabachenko/phpuserSimple non-database user class for yii2 projects
MIT
The Requires
by Viktor Kabachenko
user yii2 model
Simple non-database user class for yii2 projects
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)
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)
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)
Simple non-database user class for yii2 projects
MIT
user yii2 model