在 Zend Framework 1.8 中使用操作助手
您好,我开始使用 Zend Framework,有一个关于操作助手的问题。我的第一个应用程序是一个简单的身份验证系统(遵循书中的教程)。注册和身份验证似乎工作正常,但重定向却不行。
我有一个客户控制器,其中包含以下内容:
class CustomerController extends Zend_Controller_Action
{
// some code here......
public function authenticateAction()
{
$request = $this->getRequest();
if (!$request->isPost()) {
return $this->_helper->redirector('login');
}
// Validate
$form = $this->_forms['login'];
if (!$form->isValid($request->getPost())) {
return $this->render('login');
}
if (false === $this->_authService->authenticate($form->getValues())) {
$form->setDescription('Login failed, please try again.');
return $this->render('login');
}
return $this->_helper->redirector('index');
}
身份验证网址为 http://localhost/customer/authenticate这似乎工作正常,但它没有重定向。身份验证后,我得到一个空白页面,看起来像是它带我到索引并且就坐在那里。我尝试使用“/index”代替,但这也没有帮助。我需要做一些特殊的事情才能使重定向器帮助程序正常工作吗?我有一个行为相同的注销操作。
Hi am starting off with Zend Framework and have a question about action helpers. My first application is a simple authentication system (following a tutorial from a book). The registration and authentication seems to work fine but the redirect doesn't.
I have a customer controller that has this among others:
class CustomerController extends Zend_Controller_Action
{
// some code here......
public function authenticateAction()
{
$request = $this->getRequest();
if (!$request->isPost()) {
return $this->_helper->redirector('login');
}
// Validate
$form = $this->_forms['login'];
if (!$form->isValid($request->getPost())) {
return $this->render('login');
}
if (false === $this->_authService->authenticate($form->getValues())) {
$form->setDescription('Login failed, please try again.');
return $this->render('login');
}
return $this->_helper->redirector('index');
}
the authenticate url is http://localhost/customer/authenticate and this seems to work fine but it does not redirect. After authentication I get a blank page which looks like its taking me to the index and just sits there. I tried using '/index' instead but that did not help either. Do I need to do anything special to make the redirector helper work? I have a logout action which behaves the same.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您应该
不调用返回。
You should call
without the return.
我发现我的设置可能有问题。上面的代码是完美的,可以在另一台计算机上运行。
I found out there may be a problem with my setup. The code above is perfect, works on another computer.