Symfony3 return array from query to json -
i have problem, can't return posts array json becouse symfony returns array entity object?
its code:
public function indexaction() { $em = $this->getdoctrine()->getmanager(); $posts = $em->getrepository('appbundle:post')->findall(); return $this->json($posts); }
i use $this->json return json data, feature added on sf3. result:
[ {}, {}, {} ]
i want load posts.
ps. know, can use query builder, , method toarray or something, method use , dry? thx
a best solution enable serializer component in symfony:
#app/config/config.yml framework: serializer: ~
note: serializer component disabled default, have uncomment config line in app/config/config.yml file.
Comments
Post a Comment