Symfony 3: An exception has been thrown during the rendering

symfony, twig

Solution

In `FooBlogBundle:Article:articles.html.twig` template you have something like `{{ path(FlickBlogBundle_articles) }}` (can not tell exactly because I do not see a template). This route requires additional parameter `id`. So change it to `{{ path(FlickBlogBundle_articles, {'id':article.id}) }}`

Problem

The full error I am getting is this one. `An exception has been thrown during the rendering of a template ("Some mandatory parameters are missing ("id") to generate a URL for route "FooBlogBundle_articles".") in "FooBlogBundle:Article:articles.html.twig".` This is the controller, that handles the action: ``` public function articlesAction($id) { $em = $this->getDoctrine()->getManager(); $blog = $em->getRepository('FooBlogBundle:Blog')->find($id); if(!$em){ throw $this->createNotFoundException('Unable to find blog posti'); } return $this->render('FooBlogBundle:Article:articles.html.twig', ['blog'=>$blog]); } } ``` and the routing ``` FlickBlogBundle_articles: pattern: /foo/{id} defaults: { _controller: FooBlogBundle:Article:articles } requirements: _method: GET id: \d+ ``` Twig and database, are completely normal, no type or problems. But this error is kind of hard to spot, where I have gone wrong. EDIT: Including template: ``` {% extends 'FooBlogBundle::layout.html.twig' %} {% block body %} {{ blog.title }}<br/> {{ blog.author }}<br/> {{ blog.blog }}<br/> {{ blog.tags }}<br/> {{ blog.comments }} {% endblock %} ``` The above template is located in `views/article/` it extends another templates found at `views/` whic is just `{% extends 'FooBlogBundle::layout.html.twig' %}`

Original source