Dan*_*Dan 5 php subdomain ini routing zend-framework
我正在尝试使用Zend路由器创建子域,然后为子域下的每个部分创建子域,例如subdomain.site.com/section/我正在创建另一个路由,然后尝试将其链接到子域路由.但我不知道怎么做.我已经阅读了所有可以找到的文档和所有论坛,但它让我自己弄清楚了.到目前为止,我的尝试只是给我这个错误:
可捕获的致命错误:传递给Zend_Controller_Router_Rewrite :: addRoute()的参数2必须实现接口Zend_Controller_Router_Route_Interface,null给定,在第155行的/var/local/zend/library/Zend/Controller/Router/Rewrite.php中调用,并在/ var中定义第93行/local/zend/library/Zend/Controller/Router/Rewrite.php
使用以下代码:
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
Run Code Online (Sandbox Code Playgroud)
我找不到一个如何用网上任何地方的INI文件链接这个的例子.整个应用程序用INI编写,用于路由配置,因此我无法将其切换到基于数组的配置(或XML),其中100%的互联网示例都在其中.
如果我能以阵列形式完成,我可以这样说:
$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)
Run Code Online (Sandbox Code Playgroud)
有没有人对如何在INI文件中执行上述操作有任何想法?
jas*_*son 11
这基本上是你想要的INI格式:
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]+'
Run Code Online (Sandbox Code Playgroud)
这将为您提供以下路线:b2b-signup和b2b-anotherroute.
这里有一些关于路由链的重要说明:
将路由链接在一起时,外部路由的参数优先级高于内部路由的参数.因此,如果在外部路径和内部路径中定义控制器,则将选择外部路径的控制器.
父/子链接的路由名称始终与短划线连接!因此,如上例所示,b2b.chains.signup成为一个名为的路径b2b-signup(可用于URL组装等).
你可以继续链接!链条链可以有链子.
链式路线的孩子不能使用通配符.见#ZF-6654.这里的博客文章,讨论为什么这可能不是一个大问题.
| 归档时间: |
|
| 查看次数: |
6774 次 |
| 最近记录: |