$config = [ 'modules' => [ 'comment' => [ 'class' => 'frontend/modules/comment/Comment', ], 'article' => [ 'class' => 'frontend/modules/article/Article', 'modules' => [ 'category' => [ 'class' => 'frontend/modules/article/modules/category/Category', ], 'title' => [ 'class' => 'frontend/modules/article/modules/title/Title', ], ], ], ],];if (!YII_ENV_TEST) { // configuration adjustments for 'dev' environment $config['bootstrap'][] = 'debug'; $config['modules']['debug'] = [ 'class' => 'yii/debug/Module', ]; $config['bootstrap'][] = 'gii'; $config['modules']['gii'] = [ 'class' => 'yii/gii/Module', ];}return $config;
<?phpnamespace frontend/modules/article;/** * article module definition class */class Article extends /yii/base/Module{ /** * @inheritdoc */ public $controllerNamespace = 'frontend/modules/article/controllers'; /** * @inheritdoc */ public function init() { parent::init(); //添加子模块后 $this->modules = [ 'category' => [ 'class' => 'frontend/modules/article/modules/category/Category', ], ]; // custom initialization code goes here }}