• <tfoot id='EtOav'></tfoot>
    <legend id='EtOav'><style id='EtOav'><dir id='EtOav'><q id='EtOav'></q></dir></style></legend>

      <bdo id='EtOav'></bdo><ul id='EtOav'></ul>

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

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

        模块中的 Yii2 路由定义

        Yii2 routes definition in modules(模块中的 Yii2 路由定义)
        <i id='gF8Jw'><tr id='gF8Jw'><dt id='gF8Jw'><q id='gF8Jw'><span id='gF8Jw'><b id='gF8Jw'><form id='gF8Jw'><ins id='gF8Jw'></ins><ul id='gF8Jw'></ul><sub id='gF8Jw'></sub></form><legend id='gF8Jw'></legend><bdo id='gF8Jw'><pre id='gF8Jw'><center id='gF8Jw'></center></pre></bdo></b><th id='gF8Jw'></th></span></q></dt></tr></i><div id='gF8Jw'><tfoot id='gF8Jw'></tfoot><dl id='gF8Jw'><fieldset id='gF8Jw'></fieldset></dl></div>

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

          <tfoot id='gF8Jw'></tfoot>

                <tbody id='gF8Jw'></tbody>
              <legend id='gF8Jw'><style id='gF8Jw'><dir id='gF8Jw'><q id='gF8Jw'></q></dir></style></legend>

                • <bdo id='gF8Jw'></bdo><ul id='gF8Jw'></ul>

                  本文介绍了模块中的 Yii2 路由定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  有没有办法从模块配置中添加路由?

                  Is there any solution to add routes from module configuration?

                  示例.我们有描述

                  'components' => [
                      'urlManager' => [
                                  'enablePrettyUrl' => true,
                                  'showScriptName' => false,
                                  'rules' => require(FILE_PATH_CONFIG_ENV . '_routes.php') // return array
                      ],
                  ]
                  

                  在每个模块中,我们加载带有私有参数的自定义配置文件

                  in each module we load custom config file with private parameters

                  public function loadConfig($sFileName = 'main', $sFolderName = 'config')
                  {
                      Yii::configure($this, require($this->getBasePath() . DS . $sFolderName . DS . $sFileName . '.php'));
                  
                      return $this;
                  }
                  

                  配置文件

                  return [
                      'components' => [
                          'urlManager' => [
                              'class' => 'yiiwebUrlManager',
                              'rules' => [
                                  '/admin' => '/admin/index/index',
                              ]
                          ]
                      ]
                  ];
                  

                  现在我需要以某种方式将当前配置(主要用于 Web 应用程序)与从模块加载的配置合并.最后,我只想在模块配置路由中描述这个模块,并将它们用于漂亮的 url(用户友好的 url).我怎样才能做到这一点?这个例子在我创建 url /admin/index/index 时不起作用,它显示了我 /admin/index/index 但我想要 /admin如模块规则中所述.

                  And now I need somehow merge current config (main for web application) with config loaded from module. In end I want describe in module config routes only for this module and use them for pretty urls (user friendly url). How can I do this one? This examples not working when I create url /admin/index/index, it shows me /admin/index/index but I want /admin as mentioned in module rules.

                  推荐答案

                  模块的分隔 url 规则在官方文档中提到 这里.

                  Separating url rules for modules is mentioned in official documentation here.

                  而且我认为这是一种更优化的方法,与在一个配置文件中合并和声明所有规则不同.

                  And I think this is more optimum approach unlike merging and declaring all rules in one config file.

                  规则按照声明的顺序进行解析(这在 此处),因此通过分离,您可以跳过其他模块的 url.在大量规则的情况下,它可以提高性能.

                  The rules are parsed in order they are declared (this is mentioned here), so with the separation you can skip other modules urls. In case of large amount of rules it can give perfomance boost.

                  这篇关于模块中的 Yii2 路由定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                  PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                  mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                  Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                  Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                  Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)

                    <bdo id='iFeVI'></bdo><ul id='iFeVI'></ul>

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

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

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