PHP code example of wyanlord / yii2-rbac-vue
1. Go to this page and download the library: Download wyanlord/yii2-rbac-vue library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
wyanlord / yii2-rbac-vue example snippets
'aliases' => [
'@bower' => dirname(dirname(__DIR__)) . '/backview/node_modules',
'@npm' => dirname(dirname(__DIR__)) . '/backview/node_modules',
]
if (YII_ENV_DEV && strpos($_SERVER['REQUEST_URI'],'/gii') !== false) {
$config['bootstrap'][] = 'gii';
$config['modules']['gii'] = [
'class' => 'yii\gii\Module',
'generators' => [
'crud' => ['class' => 'wyrbac\crud\Generator']
],
];
}
'authManager' => ['class' => 'yii\rbac\DbManager']
'modules' => ['wyrbac' => 'wyrbac\Module'],
'components' => [
'request' => [
'enableCsrfValidation' => false,
'enableCookieValidation' => false,
'parsers' => ['application/json' => 'yii\web\JsonParser'],
],
'response' => [
'on beforeSend' => function ($event) {
$response = $event->sender;
if ($response->statusCode != 200) {
$response->statusCode = 200;
$response->format = yii\web\Response::FORMAT_JSON;
$response->data = [
'code' => \wyrbac\models\RespCode::ERROR_EXCEPTION,
'data' => $response->data
];
}
}
],
'user' => [
'identityClass' => 'wyrbac\models\UserModel',
'enableAutoLogin' => false,
'enableSession' => false,
],
'log' => [
'traceLevel' => YII_DEBUG ? 3 : 0,
'targets' => [
[
'class' => 'yii\log\FileTarget',
'levels' => ['error', 'warning'],
],
],
],
'errorHandler' => ['errorAction' => 'site/error'],
'authManager' => ['class' => 'yii\rbac\DbManager'],
'urlManager' => [
'enablePrettyUrl' => true,
'showScriptName' => false,
'rules' => []
],
],
class SiteController extends Controller
{
public function actionError(){
// 仅当YII_DEBUG为false时有效
$response = Yii::$app->getResponse();
$response->data = 'Server Error.';
return $response;
}
public function actionIndex(){
header('Location:'.Url::to(['/index.html'],true));exit; // 跳转到前端页面
}
}
php yii migrate --migrationPath=@console/migrations
php yii migrate --migrationPath=@yii/rbac/migrations