This error description is awful and a long time because it does not tell you what the real problem is. Try the following:
class BlogController extends FOSRestController { public function getAction($blogUri) { ... } } class PostController extends FOSRestController { public function getAction($blogUri, $postId) { ... } } class CommentController extends FOSRestController { public function getAction($blogUri, $postId, $commentId) { ... } }
You did not have the correct number of arguments in the actions of the child controller. It took me two days of debugging to figure this out.
The parent route, Blog, looks like this:
/blog/{blogUri}
It will match
public function getAction($blogUri)
Children's route, message, looks like this:
/blog/{blogUri}/post/{postId}
It will not match the code below because it needs two parameters. The same is true for a grandson - who is looking for three parameters:
public function getAction($postId)
The grandson's path, a comment, looks like this:
/blog/{blogUri}/post/{postId}/comment/{commentId}
The code tracks the ancestors of each controller. The post has 1 ancestor. When building routes for the post controller, the code looks at the number of parameters in the "get action". It takes the number of parameters and subtracts the number of ancestors. If the difference is not equal to one, it throws an error.
The conclusion for each descendant should include the identification parameters of its ancestors and its own identifier. There should always be one more parameter than the ancestors.
dlporter98
source share