Код: Выделить всё
php yii migrate/up --migrationPath=@yii/rbac/migrations
Yii Migration Tool (based on Yii v2.0.14.1)
Total 2 new migrations to be applied:
m140506_102106_rbac_init
m170907_052038_rbac_add_index_on_auth_assignment_user_id
Apply the above migrations? (yes|no) [no]:y
*** applying m140506_102106_rbac_init
Exception 'yii\base\InvalidConfigException' with message 'You should configure "authManager" component to use database before executing this migration.'
in C:\OSPanel\domains\yii2\vendor\yiisoft\yii2\rbac\migrations\m140506_102106_rbac_init.php:27
Stack trace:
#0 C:\OSPanel\domains\yii2\vendor\yiisoft\yii2\rbac\migrations\m140506_102106_rbac_init.php(51): m140506_102106_rbac_init->getAuthManager()
#1 C:\OSPanel\domains\yii2\vendor\yiisoft\yii2\console\controllers\BaseMigrateController.php(725): m140506_102106_rbac_init->up()
#2 C:\OSPanel\domains\yii2\vendor\yiisoft\yii2\console\controllers\BaseMigrateController.php(199): yii\console\controllers\BaseMigrateController->migrateUp('m140506_102106_...')
#3 [internal function]: yii\console\controllers\BaseMigrateController->actionUp(0)
#4 C:\OSPanel\domains\yii2\vendor\yiisoft\yii2\base\InlineAction.php(57): call_user_func_array(Array, Array)
#5 C:\OSPanel\domains\yii2\vendor\yiisoft\yii2\base\Controller.php(157): yii\base\InlineAction->runWithParams(Array)
#6 C:\OSPanel\domains\yii2\vendor\yiisoft\yii2\console\Controller.php(148): yii\base\Controller->runAction('up', Array)
#7 C:\OSPanel\domains\yii2\vendor\yiisoft\yii2\base\Module.php(528): yii\console\Controller->runAction('up', Array)
#8 C:\OSPanel\domains\yii2\vendor\yiisoft\yii2\console\Application.php(180): yii\base\Module->runAction('migrate/up', Array)
#9 C:\OSPanel\domains\yii2\vendor\yiisoft\yii2\console\Application.php(147): yii\console\Application->runAction('migrate/up', Array)
#10 C:\OSPanel\domains\yii2\vendor\yiisoft\yii2\base\Application.php(386): yii\console\Application->handleRequest(Object(yii\console\Request))
#11 C:\OSPanel\domains\yii2\yii(20): yii\base\Application->run()
#12 {main}
Код: Выделить всё
<?php
$params = require __DIR__ . '/params.php';
$db = require __DIR__ . '/db.php';
$config = [
'id' => 'basic',
'basePath' => dirname(__DIR__),
'bootstrap' => ['log'],
'modules' => [
'admin' => [
'class' => 'app\modules\admin\Module',
],
'rbac' => [
'class' => 'yii2mod\rbac\Module',
],
'user-management' => [
'class' => 'webvimark\modules\UserManagement\UserManagementModule',
// 'enableRegistration' => true,
// Add regexp validation to passwords. Default pattern does not restrict user and can enter any set of characters.
// The example below allows user to enter :
// any set of characters
// (?=\S{8,}): of at least length 8
// (?=\S*[a-z]): containing at least one lowercase letter
// (?=\S*[A-Z]): and at least one uppercase letter
// (?=\S*[\d]): and at least one number
// $: anchored to the end of the string
//'passwordRegexp' => '^\S*(?=\S{8,})(?=\S*[a-z])(?=\S*[A-Z])(?=\S*[\d])\S*$',
// Here you can set your handler to change layout for any controller or action
// Tip: you can use this event in any module
'on beforeAction'=>function(yii\base\ActionEvent $event) {
if ( $event->action->uniqueId == 'user-management/auth/login' )
{
$event->action->controller->layout = 'loginLayout.php';
};
},
],
],
'aliases' => [
'@bower' => '@vendor/bower-asset',
'@npm' => '@vendor/npm-asset',
],
'components' => [
'request' => [
// !!! insert a secret key in the following (if it is empty) - this is required by cookie validation
'cookieValidationKey' => 'XvI88i7mwBi7lxTjXiTTio1Mfi2kl9Ne',
],
'authManager' => [
'class' => 'yii\rbac\DbManager',
'defaultRoles' => ['guest', 'user'],
],
'cache' => [
'class' => 'yii\caching\FileCache',
],
'user' => [
'identityClass' => 'app\models\User',
'enableAutoLogin' => true,
],
'errorHandler' => [
'errorAction' => 'site/error',
],
'mailer' => [
'class' => 'yii\swiftmailer\Mailer',
// send all mails to a file by default. You have to set
// 'useFileTransport' to false and configure a transport
// for the mailer to send real emails.
'useFileTransport' => true,
],
'log' => [
'traceLevel' => YII_DEBUG ? 3 : 0,
'targets' => [
[
'class' => 'yii\log\FileTarget',
'levels' => ['error', 'warning'],
],
],
],
'db' => $db,
'urlManager' => [
'enablePrettyUrl' => true,
'showScriptName' => false,
'rules' => [
],
],
'user' => [
'class' => 'webvimark\modules\UserManagement\components\UserConfig',
// Comment this if you don't want to record user logins
'on afterLogin' => function($event) {
\webvimark\modules\UserManagement\models\UserVisitLog::newVisitor($event->identity->id);
}
],
],
'params' => $params,
];
if (YII_ENV_DEV) {
// configuration adjustments for 'dev' environment
$config['bootstrap'][] = 'debug';
$config['modules']['debug'] = [
'class' => 'yii\debug\Module',
// uncomment the following to add your IP if you are not connecting from localhost.
//'allowedIPs' => ['127.0.0.1', '::1'],
];
$config['bootstrap'][] = 'gii';
$config['modules']['gii'] = [
'class' => 'yii\gii\Module',
// uncomment the following to add your IP if you are not connecting from localhost.
//'allowedIPs' => ['127.0.0.1', '::1'],
];
}
return $config;