I’ve set up a route using annotations. Looks right to me, Symfony2 says it’s wrong. Here’s the route:
@Route("/news/{id}/{slug}", name="newsarticle")
Here’s a sample URL which I think matches the route:
Here is the function skeleton:
public function newsArticleAction($id, $slug)
{
}
What am I missing here? I get a 500 error and the log says:
[2012-10-30 20:36:35] request.INFO: Matched route “newsarticle” (parameters: “_controller”: “App\SiteBundle\Controller\DefaultController::newsArticleAction”, “id”: “202”, “slug”: “my-news-title”, “_route”: “newsarticle”) [] []
[2012-10-30 20:36:36] app.INFO: From listener: The “newsarticle” route has some missing mandatory parameters (“id”). [] []
[2012-10-30 20:36:36] request.CRITICAL: Symfony\Component\Routing\Exception\MissingMandatoryParametersException: The “newsarticle” route has some missing mandatory parameters (“id”). (uncaught exception) at /home/user/app/cache/prod/classes.php line 676 [] []
This error comes up not when matching a URL to a route, but when generating a URL from a route.
Search your project for
path('newsarticle'orgenerateUrl('newsarticle'. You should find an attempt to generate a URL without passing all the needed parameters — something like:while it has to look like: