对“ URI的控制器不可调用”进行故障排除。错误 [英] Troubleshooting "The controller for URI is not callable" error
问题描述
我正在使用 Symfony 2.3 ,并且声明了新的 route 和新的 controller ,但是当我从浏览器中调用此控制器时我收到此错误:
I'm working on Symfony 2.3 and I declared a new route and new controller, but when I call this controller from the browser I get this error:
URI的控制器 / user / 1不可调用。在/dev.mydomain.org/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Controller/ControllerResolver.php中的第82行
这是我简单的 route 配置:
user_homepage:
pattern: /user
defaults: { _controller: UserBundle:Default:index }
user_show:
pattern: /user/{id}
defaults: { _controller: UserBundle:Default:show }
requirements:
id: \d+
这是我的控制器:
public function showUserAction($id)
{
return $this->render('UserBundle:Default:show.html.twig', array());
}
怎么了?
推荐答案
逻辑名称 UserBundle:Default:show
指的是 UserBunde\Controller\DefaultController: :showAction
,您有一个名为 showUserAction
的方法。
The logical name UserBundle:Default:show
refers to UserBunde\Controller\DefaultController::showAction
you have a method called showUserAction
.
将方法名称更改为 showAction
或将逻辑名称更改为 UserBundle:Default:showUser
。
Either change the method name to showAction
or change the logical name to UserBundle:Default:showUser
.
这篇关于对“ URI的控制器不可调用”进行故障排除。错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!