第0步:composer selfupdate
第一步:
composer update yiisoft/yii2-composer --no-plugins
第1.5步:
php -r "readfile('https://getcomposer.org/installer');" | php
第二步:
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