Home > Article > PHP Framework > How to develop modules in yii2
yii2 Model creation can be created through the gii tool, which is convenient and fast (recommended learning: yii tutorial)
yii2 Yes Create a modules folder in the root directory of the project to store each module. Of course, you can also create additional modules in each module
1. Create a module directly in the root directory of the project
Look at the screenshot--"Then click Preview--"generate to generate the payment module
Don't forget one operation at this time!!!!!!!!! !!!!!!
The above prompts to add the model namespace to the configuration file: For the basic version, open web.php and add the following mapping relationship to the $config array
'modules' => [ 'payment' => [ 'class' => 'app\modules\payment\Payment', ], ],
Then you can access the corresponding route in the browser. . It can be the following
r=payment 默认找到payment/default/index r=payment/default gii默认创建了default控制器和index操作 r=payment/default/index 这个可以访问,上面说过了
The above is the detailed content of How to develop modules in yii2. For more information, please follow other related articles on the PHP Chinese website!