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

    <tfoot id='wjRGb'></tfoot>

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

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

    1. 如何在路由 INI 文件中为 Zend 框架中的子域编写路由链?

      时间:2023-10-31
      1. <tfoot id='CVJZS'></tfoot>
          1. <i id='CVJZS'><tr id='CVJZS'><dt id='CVJZS'><q id='CVJZS'><span id='CVJZS'><b id='CVJZS'><form id='CVJZS'><ins id='CVJZS'></ins><ul id='CVJZS'></ul><sub id='CVJZS'></sub></form><legend id='CVJZS'></legend><bdo id='CVJZS'><pre id='CVJZS'><center id='CVJZS'></center></pre></bdo></b><th id='CVJZS'></th></span></q></dt></tr></i><div id='CVJZS'><tfoot id='CVJZS'></tfoot><dl id='CVJZS'><fieldset id='CVJZS'></fieldset></dl></div>
              <tbody id='CVJZS'></tbody>
              <bdo id='CVJZS'></bdo><ul id='CVJZS'></ul>
              <legend id='CVJZS'><style id='CVJZS'><dir id='CVJZS'><q id='CVJZS'></q></dir></style></legend>

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

                本文介绍了如何在路由 INI 文件中为 Zend 框架中的子域编写路由链?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我正在尝试使用 Zend 路由器创建一个子域,然后对于子域下的每个部分,例如 subdomain.site.com/section/,我正在创建另一个路由,然后尝试将其链接到子域路由.但我不知道怎么做.我已经阅读了我能找到的所有文档和所有论坛,但它让我自己弄清楚.到目前为止,我的尝试只是给我这个错误:

                I am trying to create a subdomain using the Zend Router, and then for each section under a subdomain, such as subdomain.site.com/section/ I am creating another route and then trying to chain it to the subdomain route. but I don't know how. I have read all the documentation I could find and all the forums, but it leads me to figure it out on my own. So far, my attempts just get me this error:

                可捕获的致命错误:参数 2 传递给Zend_Controller_Router_Rewrite::addRoute() 必须实现接口Zend_Controller_Router_Route_Interface,null 给定,调用/var/local/zend/library/Zend/Controller/Router/Rewrite.php 在第 155 行并定义在/var/local/zend/library/Zend/Controller/Router/Rewrite.php 在第 93 行

                Catchable fatal error: Argument 2 passed to Zend_Controller_Router_Rewrite::addRoute() must implement interface Zend_Controller_Router_Route_Interface, null given, called in /var/local/zend/library/Zend/Controller/Router/Rewrite.php on line 155 and defined in /var/local/zend/library/Zend/Controller/Router/Rewrite.php on line 93

                使用以下代码:

                routes.b2b.type = "Zend_Controller_Router_Route_Hostname"
                routes.b2b.route = "sales.sitename.com"
                routes.b2b.defaults.module = b2b
                routes.b2b.defaults.controller = index
                routes.b2b.defaults.action = index
                
                routes.b2b_signup.type = "Zend_Controller_Router_Route_Static"
                routes.b2b_signup.route = "/signup"
                routes.b2b_signup.defaults.controller = "index"
                routes.b2b_signup.defaults.action   = "signup"
                
                routes.b2b_login.type = "Zend_Controller_Router_Route_Chain"
                routes.b2b_login.chain = b2b_signup
                

                我在网络上的任何地方都找不到如何将其与 INI 文件链接的示例.整个应用程序是在路由配置的 INI 中编写的,因此我无法将其切换到基于数组的配置(或 XML 相关),互联网上 100% 的示例都在其中.

                I cannot find an example of how to do chaining this with an INI file anywhere on the net. The entire application is written in an INI for the routing config, so I can't switch it over to an array based config (or XML for that matter), in which 100% of the examples on the internet are in.

                如果我能以数组的形式做到这一点,我可以这样说:

                If I could do it in array form, I could just say this:

                $hostnameRoute = new Zend_Controller_Router_Route_Hostname(
                    'sales.sitename.com',
                    array(
                        'controller' => 'index',
                        'module'     => 'b2b',
                        'action'     => 'index'
                    )
                );
                
                $hostnameRoute = new Zend_Controller_Router_Route_Static(
                    '/signup',
                    array(
                        'controller' => 'index',
                        'module'     => 'b2b',
                        'action'     => 'signup'
                    )
                );
                    $chainedRoute = new Zend_Controller_Router_Route_Chain();
                    $chainedRoute->chain($b2b_signup)
                

                有人对如何在 INI 文件中执行上述操作有任何想法吗?

                Does anyone have any ideas on how to do the above in an INI file?

                推荐答案

                这基本上就是你想要的,INI 格式:

                Here's basically what you want, in INI format:

                routes.b2b.type = "Zend_Controller_Router_Route_Hostname"
                routes.b2b.route = "sales.sitename.com"
                ; you could specify a default module (or anything) to use for the whole 
                ; route chain here, like so: 
                ; routes.b2b.defaults.module = "default"
                
                routes.b2b.chains.signup.type = "Zend_Controller_Router_Route_Static"
                routes.b2b.chains.signup.route = "/signup"
                routes.b2b.chains.signup.defaults.controller = "index"
                routes.b2b.chains.signup.defaults.action = "signup"
                
                routes.b2b.chains.anotherroute.route = "/something/:foo" ; etc, etc.
                routes.b2b.chains.anotherroute.defaults.action = "foo"
                routes.b2b.chains.anotherroute.defaults.controller = "index"
                routes.b2b.chains.anotherroute.defaults.foo = "bar"
                routes.b2b.chains.anotherroute.reqs.foo = '[a-z]+'
                

                这将为您提供以下路线:b2b-signupb2b-anotherroute.

                This will give you the following routes: b2b-signup, and b2b-anotherroute.

                这里有一些关于路由链的重要说明:

                Here's some important notes on route chaining:

                将路由链接在一起时,外部路由的参数优先级高于内部路由的参数.因此,如果你在外部路由和内部路由中定义了一个控制器,就会选择外部路由的控制器.

                When chaining routes together, the parameters of the outer route have a higher priority than the parameters of the inner route. Thus if you define a controller in the outer and in the inner route, the controller of the outer route will be selected.

                父/子链式路由名称总是用破折号连接!所以,就像上面的例子一样,b2b.chains.signup 变成了一个名为 b2b-signup 的路由(你可以用它来组装 URL 等等).

                Parent / child chained route names are always concatenated with a dash! So, like in the example above, b2b.chains.signup becomes a route named b2b-signup (which you can use for URL assembly, etc).

                你可以继续链接!链链可以有链.

                You can keep chaining! Chains of chains can have chains.

                链式路由的子级不能使用通配符.请参阅 #ZF-6654.这是博文谈论为什么这可能没什么大不了的.

                Children of chained routes do not work with wildcards. See #ZF-6654. Here's blog post that talks about why that may not be a big deal.

                这篇关于如何在路由 INI 文件中为 Zend 框架中的子域编写路由链?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:带有 PUT 方法的 Laravel 表单 html 用于 PUT 路由 下一篇:Mod-Rewrite 还是 PHP 路由器?

                相关文章

                  <bdo id='Kb0xc'></bdo><ul id='Kb0xc'></ul>
              • <small id='Kb0xc'></small><noframes id='Kb0xc'>

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

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