您好,登錄后才能下訂單哦!
本篇文章給大家分享的是有關(guān)怎么在YII框架中進(jìn)行模塊化處理,小編覺得挺實(shí)用的,因此分享給大家學(xué)習(xí),希望大家閱讀完這篇文章后可以有所收獲,話不多說,跟著小編一起來看看吧。
具體如下:
config.php
$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;
添加子模塊后,在父模塊添加管理入口配置,實(shí)現(xiàn)父模塊管理子模塊功能,如果父模塊出現(xiàn)bug,子模塊將無法繼續(xù)使用
<?php namespace 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 } }
以上就是怎么在YII框架中進(jìn)行模塊化處理,小編相信有部分知識(shí)點(diǎn)可能是我們?nèi)粘9ぷ鲿?huì)見到或用到的。希望你能通過這篇文章學(xué)到更多知識(shí)。更多詳情敬請(qǐng)關(guān)注億速云行業(yè)資訊頻道。
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。