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:
The controller for URI "/user/1" is not callable. in /dev.mydomain.org/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Controller/ControllerResolver.php at line 82
This is my simple route configuration:
user_homepage:
pattern: /user
defaults: { _controller: UserBundle:Default:index }
user_show:
pattern: /user/{id}
defaults: { _controller: UserBundle:Default:show }
requirements:
id: \d+
And this is my very simple controller:
public function showUserAction($id)
{
return $this->render('UserBundle:Default:show.html.twig', array());
}
What is wrong?
In my case, i was using symfony 2.
Prior version of symfony maintain method naming convention. Method suffix should contain Action word.
example:
in route yml file the method definition was
and in the controller the method was
therefore i was getting the error.
After changing the method name to
public function makeAuthorizationAction
it worked perfectly.You're defining your controller function as
showUserAction
while in the definition your saying it isshow[Action]
.Either change your route configuration
or change your controller signature
See if this helps
The logical name
UserBundle:Default:show
refers toUserBunde\Controller\DefaultController::showAction
you have a method calledshowUserAction
.Either change the method name to
showAction
or change the logical name toUserBundle:Default:showUser
.After big search, this worked for me:
1.- Create CRUDController
2.- Create the service
3.- Create the template for the action button
4.- Configure route
5.- Clear cache
Hope it helps
One of the reasons for this error is that you missed to add the word "Action" after the controller's method name. If you think that your routing is OK, check the method name.
Although not relevant to the example given, this error can also be caused if the controller Action is not public