I have a little problem, because I have to show json date with database in Symfony3.
My controller
/**
* @Route("/api/rest", name="rest_api")
*
*
* @Template
*/
public function indexAction(Request $Request) {
$Repo = $this->getDoctrine()->getRepository('CommonUserBundle:Comment');
$row = $Repo->findAll();
$data = json_encode($row, true);
return array(
'comment' => $data
);
}
And this is my layout in html.twig
{% for comments in comment %}
{{ comments }}
{% endfor %}
But I don't know why nothing show. Help me please :)