<legend id='cONnQ'><style id='cONnQ'><dir id='cONnQ'><q id='cONnQ'></q></dir></style></legend>

    • <bdo id='cONnQ'></bdo><ul id='cONnQ'></ul>
  • <tfoot id='cONnQ'></tfoot>

    1. <small id='cONnQ'></small><noframes id='cONnQ'>

      <i id='cONnQ'><tr id='cONnQ'><dt id='cONnQ'><q id='cONnQ'><span id='cONnQ'><b id='cONnQ'><form id='cONnQ'><ins id='cONnQ'></ins><ul id='cONnQ'></ul><sub id='cONnQ'></sub></form><legend id='cONnQ'></legend><bdo id='cONnQ'><pre id='cONnQ'><center id='cONnQ'></center></pre></bdo></b><th id='cONnQ'></th></span></q></dt></tr></i><div id='cONnQ'><tfoot id='cONnQ'></tfoot><dl id='cONnQ'><fieldset id='cONnQ'></fieldset></dl></div>

        如何在 YII2 中创建模块

        时间:2023-10-16
        <i id='lZEEu'><tr id='lZEEu'><dt id='lZEEu'><q id='lZEEu'><span id='lZEEu'><b id='lZEEu'><form id='lZEEu'><ins id='lZEEu'></ins><ul id='lZEEu'></ul><sub id='lZEEu'></sub></form><legend id='lZEEu'></legend><bdo id='lZEEu'><pre id='lZEEu'><center id='lZEEu'></center></pre></bdo></b><th id='lZEEu'></th></span></q></dt></tr></i><div id='lZEEu'><tfoot id='lZEEu'></tfoot><dl id='lZEEu'><fieldset id='lZEEu'></fieldset></dl></div>

        <small id='lZEEu'></small><noframes id='lZEEu'>

        <legend id='lZEEu'><style id='lZEEu'><dir id='lZEEu'><q id='lZEEu'></q></dir></style></legend>

        <tfoot id='lZEEu'></tfoot>
          <bdo id='lZEEu'></bdo><ul id='lZEEu'></ul>

                <tbody id='lZEEu'></tbody>
                • 本文介绍了如何在 YII2 中创建模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  如何在 yii2 中创建模块并在配置上设置相同的模块.我在谷歌上搜索了一段时间,但找不到那么多教程.请帮忙.

                  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

                  1. 在您的应用程序基本路径上创建一个模块文件夹.这将与您当前运行的应用程序的 @app 别名相对应.这与高级模板中的基本模板或后端/前端的根文件夹相同.

                  1. Create a modules folder on your application base path. This would be what corresponds to your @app alias of your currently running application. This is the same as the root folder of basic template or backend/frontend in the advanced template.

                  在您的模块文件夹中,为您的模块创建一个与模块 ID 相对应的文件夹.

                  Inside your modules folder create a folder for your module corresponding to the Module ID.

                  你的模块类应该在这个模块文件夹中并且应该扩展yiiaseModule.这是您的模块类的基本工作示例.

                  Your Module Class should be inside this module folder and should extend yiiaseModule. This is a basic working example for your module class.

                  <?php
                  
                  namespace appmoduleshome;
                  
                  class Home extends yiiaseModule
                  {
                     public $controllerNamespace = 'appmoduleshomecontrollers';
                  
                     public function init()
                     {
                         parent::init();
                  
                         // custom initialization code goes here
                     }
                  }
                  

                • 在同一文件夹中创建模块控制器、模型和视图文件夹.

                • Create your module controller, models and views folder on the same folder.

                  要访问该模块,您需要将其添加到您的应用程序配置中:

                  To access the module, you need to add this to your application configuration:

                  <?php
                  ......
                     'modules' => [
                        'home' => [
                           'class' => 'appmoduleshomeHome',
                        ],
                     ],
                  ......
                  

                • 选项 2

                  1. 如果您使用 Gii 模块,请转到模块生成器并输入模块类的路径.这将与选项中的 appmoduleshomeHome 相同1

                  预览并生成所有文件.根据您的模块类更改应用程序配置,如选项 1 中所述.

                  Preview and Generate all files. Change application configuration as in Option 1 according to your module class.

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

                  上一篇:Yii2框架如何处理CSRF验证? 下一篇:如何在没有控制台访问权限的主机上处理 yii2 迁移?

                  相关文章

                  1. <legend id='vI2we'><style id='vI2we'><dir id='vI2we'><q id='vI2we'></q></dir></style></legend>
                    • <bdo id='vI2we'></bdo><ul id='vI2we'></ul>
                    <tfoot id='vI2we'></tfoot>

                    <small id='vI2we'></small><noframes id='vI2we'>

                      <i id='vI2we'><tr id='vI2we'><dt id='vI2we'><q id='vI2we'><span id='vI2we'><b id='vI2we'><form id='vI2we'><ins id='vI2we'></ins><ul id='vI2we'></ul><sub id='vI2we'></sub></form><legend id='vI2we'></legend><bdo id='vI2we'><pre id='vI2we'><center id='vI2we'></center></pre></bdo></b><th id='vI2we'></th></span></q></dt></tr></i><div id='vI2we'><tfoot id='vI2we'></tfoot><dl id='vI2we'><fieldset id='vI2we'></fieldset></dl></div>