0
我已经创建了一组类,并且想使用Zend路由器路由它们。我可以使用没有Zend结构的Zend路由器吗?
我的结构遵循以下模式:
/php/
/REST/
index.php
ClassOneService.php
ClassTwoService.php
ClassThreeService.php
我想有机会获得跨越URL类的方法(ClassOneService.php,...,ClassNService.php),例如:
class ClassOneService extends Connect {
public function test() {
echo 'hello';
}
}
跨越
http://localhost/php/REST/classe_one/test
我的问题是:我可以在没有在Zend中转换我的应用程序格式的情况下使用Zend的系统路由吗?
不想使用MVC模式,也不想将我的类扩展到Zend Controller的类,只需使用Zend路由器路由我的方法。
好了,但我把德addRoute里面?我试图做此'$ rewrite-> addRoute( 'class_one',新Zend_Controller_Router_Route中( 'class_one /', 阵列( '控制器'=> 'ClassOneService', '动作'=> '测试' ) ));'但不工作,即时通讯不知道我是否可以在这里使用任何类,并在文档中没有任何提到使用ZendController作用域的其他类。 –
您可以使用zend_route设置路由,但是您需要编写自己的代码来管理重定向。 'foreach($ rewrite-> getRoutes()as $ route){if($ route-> match($ path){// matched,get route parts and redirect}}' – Rijndael
Thanks !!这帮了我很多!可以实现路由到我的类。 –