This article takes the Yii2 basic application template as an example to introduce the process of adding new modules to the framework:
##1. Create new module-related directories and files
step 1: Create a new directory structure(Recommended learning:yii tutorial)
First create a new modules directory in the root directory, and then add the module directory below this directory. Assuming that we need to add a user module here, we can name the directory user, and then add three directories, models, views, and controllers, under the user directory.As shown below:
step 2: Add module class file
Take adding user module as an example, we This class file can be ordered as UserModule.php. Note that this class needs to inherit yii\base\ModuleCopy after login
2. The configuration module
is mainly in config/ Add relevant configurations to web.php. The configuration information is as follows:'modules'=>array( 'user'=>[ 'class'=>'app\modules\user\UserModule', ] ),
The above is the detailed content of Where is the yii add module?. For more information, please follow other related articles on the PHP Chinese website!