【发布时间】:2015-02-07 08:40:20
【问题描述】:
我面临以下问题,错误看起来像这样;
An error occurred
An error occurred during execution; please try again later.
Additional information:
Zend\Mvc\Exception\DomainException
File: .../vendor/zendframework/zendframework/library/Zend/Mvc/Controller/Plugin/Url.php:63
Message:
Url plugin requires that controller event compose a router; none found
我在尝试从控制器重定向时从未遇到过这个问题。假设我在控制器中实现了以下重定向功能,这会产生上述错误;
public function __construct()
{
# Get user identity
$auth = new AuthenticationService();
if ($auth->hasIdentity()) {
$this->identity = $auth->getIdentity();
} else {
$this->redirect()->toRoute('admin/login');
}
}
路由确实存在,因为我可以到达 site.com/admin/login/ .. login 是 admin 的子级,因此符号必须是好的。我想知道出了什么问题以及如何解决这个问题,甚至在哪里寻找它也是一个很好的起点。
谢谢!
【问题讨论】:
标签: php redirect routing zend-framework2