yii2模块化

$params = require __DIR__ . '/params.php';
$db = require __DIR__ . '/db.php';
$modules = require __DIR__ .'/../modules/modules.php';//文件引入
 
$config = [
    'id' => 'basic',
    'modules' => $modules,//检查modules名称有没有写错
    'basePath' => dirname(__DIR__),
    'vendorPath' => '/data/www/yii2-vendor',
    'defaultRoute' => 'study/stock/emily-spoken-english',//resume/advantage/index,
    ...
 
    //这一堆原来是注释的,要放出来 
    'urlManager' => [
         'enablePrettyUrl' => true,
         'showScriptName' => false,
         'rules' => [
          ],
     ],
yii2模块化_第1张图片
image.png
modules.php的内容

return [
    'resume' => [
        'class' => 'app\modules\resume\Module'
    ],
 
    'study' => [
        'class' => 'app\modules\study\Module'
    ]
 
];
Module.php的内容

namespace app\modules\study;
 
class Module extends \yii\base\Module
{
    public function init()
    {
        parent::init();
 
        //$this->layout ='@app/modules/resume/layouts/main.php';
        $this->viewPath = '@app/modules/study/views';
    }

}

你可能感兴趣的:(yii2模块化)