Php 无法使用ZF1.12重定向程序帮助程序在try/catch中重定向

Php 无法使用ZF1.12重定向程序帮助程序在try/catch中重定向,php,zend-framework,redirect,helper,Php,Zend Framework,Redirect,Helper,我正面临一个奇怪的问题。似乎我无法在catch(){}表达式中使用ZF1.12RedirectorHelper。这是我的密码: try { $scp = new My_Controller_Plugin_Scp(); $scp->auth(); } catch(Exception $e) { echo $e->getMessage(); // $this->getHelper('Redirector')-

我正面临一个奇怪的问题。似乎我无法在
catch(){}
表达式中使用ZF1.12
Redirector
Helper。这是我的密码:

    try {
        $scp = new My_Controller_Plugin_Scp();
        $scp->auth();
    } catch(Exception $e) {
        echo $e->getMessage();
     // $this->getHelper('Redirector')->setGotoRoute(array(), 'routeName');
        $this->_helper->redirector->gotoUrl('/url/');
        exit();
    }
在助手(注释掉的行)中使用路由名称在
catch(){}
表达式中似乎不起作用。代码被解释为当我手动转到另一个页面(错误页面上显示echo$e->getMessage())时会出现flash消息,但它不会重定向到应该重定向的位置,因为我只剩下一个空白页面。当然,注释后的下一行正在运行

我想使用路由名称,因为我可能会在以后更改URL


非常感谢。

正如您所注意到的,gotoRoute是您正在寻找的东西:

try {

    throw new Exception('test');
} catch(Exception $e) {
    //displaying message before redirect is not a good idea.
    //Use flash messages
    echo $e->getMessage();

    $this->_helper->redirector->gotoRouteAndExit(array(), 'home');
}

显然,我需要使用
gotoRoute()
方法,而不是
setGotoRoute()