如您所知,Zend Framework(v1.10)使用基于斜杠分隔参数的路由,例如。基于标准PHP查询字符串的路由
[server]/controllerName/actionName/param1/value1/param2/value2/
Queston是:如何强制Zend框架,使用标准的PHP查询字符串以检索动作和控制器的名称,在这种情况下:
[server]?controller=controllerName&action=actionName¶m1=value1¶m2=value2
我已经试过:
protected function _initRequest()
{
// Ensure the front controller is initialized
$this->bootstrap('FrontController');
// Retrieve the front controller from the bootstrap registry
$front = $this->getResource('FrontController');
$request = new Zend_Controller_Request_Http();
$request->setControllerName($_GET['controller']);
$request->setActionName($_GET['action']);
$front->setRequest($request);
// Ensure the request is stored in the bootstrap registry
return $request;
}
但它不适合我。
它几乎工作,我不得不从Zend_Controller_Router_Rewrite扩展My_Router或实现其余的接口方法。第一种解决方案更快;)现在它工作得很好。谢谢! – singles 2010-03-06 15:14:24
根据手册,你应该只需要实现该方法。该API似乎说不然,所以我很困惑。你也可以尝试扩展Zend_Controller_Router_Abstract而不是Zend_Controller_Router_Rewrite。他们在手册中需要一个更好的例子。 – smack0007 2010-03-06 16:13:35