如何在YII2中创建模块 [英] How to create modules in YII2

查看:63
本文介绍了如何在YII2中创建模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在yii2中创建模块并在配置上进行设置.我已经在Google上搜索了一段时间,但找不到太多的教程. 请帮忙.

How to create a module in yii2 and setting up the same on configuration. I've been searching a while on google and I cannot find that much tutorial on it. Please help.

推荐答案

  1. 在yii2中安装 Gii .使用文档.
  2. 然后使用模块生成器.您需要Web权限才能为该文件夹创建文件,也可以复制粘贴生成的代码并手动创建指定的文件.
  3. 生成完成后,将向您显示绿色文本.对于尝试模块"(当文件夹具有Web权限时)或将以下代码复制到模块下的main.php配置文件中.用您的模块名替换模块名.

  1. Install Gii in yii2. Use documentation.
  2. Then use module generator. You need the web permission to create the file for the the folder OR you can copy paste the generated code and create the specified file manually.
  3. When generation is complete it will show you a green text. For try module" (When folder have the web permission) OR Copy following code to main.php configuration file under module. Replace modulename with yours.

'modules' => [
    'modulename' => [
         'class' => 'app\modules\modulename\Module',
    ],
]

如果仍有疑问,请发表评论.我将进行编辑以使其更有意义.

Please leave comment if still have confusion. I will edit to make this more sense.

这篇关于如何在YII2中创建模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆