安装yii2-admin(详细版本)
【摘要】
第0步:composer selfupdate 第一步:
composer update yiisoft/yii2-composer --no-plugins
第二步:
php composer....
第0步:composer selfupdate
第一步:
composer update yiisoft/yii2-composer --no-plugins
第二步:
php composer.phar require mdmsoft/yii2-admin "~2.0"
第三步(frontend\config\main.php):
<?php
$params = array_merge(
require(__DIR__ . '/../../common/config/params.php'),
require(__DIR__ . '/../../common/config/params-local.php'),
require(__DIR__ . '/params.php'),
require(__DIR__ . '/params-local.php')
);
return [
'modules' => [
'admin' => [
'class' => 'mdm\admin\Module',
'layout' => 'left-menu',
]
],
'id' => 'app-frontend',
'basePath' => dirname(__DIR__),
'bootstrap' => ['log'],
'controllerNamespace' => 'frontend\controllers',
'components' => [
'authManager' => [
'class' => 'yii\rbac\DbManager', // 使用数据库管理配置文件
],
'user' => [
'identityClass' => 'common\models\User',
'enableAutoLogin' => true,
],
'log' => [
'traceLevel' => YII_DEBUG ? 3 : 0,
'targets' => [
[
'class' => 'yii\log\FileTarget',
'levels' => ['error', 'warning'],
],
],
],
'errorHandler' => [
'errorAction' => 'site/error',
],
/*
'urlManager' => [
'enablePrettyUrl' => true,
'showScriptName' => false,
'rules' => [
],
],
*/
],
'as access' => [
'class' => 'mdm\admin\components\AccessControl',
'allowActions' => [
'site/*', //sites for access
'admin/*', // allow everyone to access 'admin'
]
],
'params' => $params,
];
第四步:
yii migrate --migrationPath=@mdm/admin/migrations
第五步:
\common\config\main.php下
<?php
return [
'vendorPath' => dirname(dirname(__DIR__)) . '/vendor',
'components' => [
'cache' => [
'class' => 'yii\caching\FileCache',
],
'authManager' => [
'class' => 'yii\rbac\DbManager',
],
],
];
第六步:
yii migrate --migrationPath=@yii/rbac/migrations
文章来源: blog.csdn.net,作者:贵哥的编程之路(热爱分享),版权归原作者所有,如需转载,请联系作者。
原文链接:blog.csdn.net/qq_37805832/article/details/122876620
【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
评论(0)