The modularity of the YII2 is the ability to make separate modules for easy scaling and porting.
In this way, other YII2 directories need to use the module is copied out, and then configure the next main can be used.
Similar to such a directory, modules is the YII2 of the modular directory, which is written in separate modules.
650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M02/7B/65/wKiom1bNA3_BWIfIAAAmWmXp-y4441.png "title=" Qq20160224091208.png "alt=" Wkiom1bna3_bwifiaaamwmxp-y4441.png "/>
Each individual module can have a corresponding controllers,models,views,
The submodule must be declared in the parent module's Yii\base\module::modules property, for example:
Namespace Common\modules\rbac;use \yii\base\module;class Rabcmodule extends module{public function init () { Parent::init (); }}
Configure the module in the main.php configuration file to allow it to be accessed independently
return [' id ' = ' app-backend ', ' basepath ' + dirname (__dir__), ' controllernamespace ' = ' Backend\contro ' Llers ', ' bootstrap ' = [' log '], ' modules ' = [], ' components ' = = [],//module configuration start ' Modules ' =&G T [' rabc ' = [' class ' = ' Common\modules\rbac\rabcmodule ',],],//module configuration end ' params ' = $params,];
As long as there are files in the controllers can be accessed, such as permissioncontroller.php
namespace Common\modules\rbac\controllers;use yii;use Backend\controllers\basecontroller;class Permissioncontroller extends basecontroller{public Function Actionindex () {return $this->render (' index ') ; }}
Access Link: http://127.0.0.1/index.php?r=rabc/permission/index
YII2 Modules Modular