Empty JSON Return - Symfony3

Viewed 3578

I am a beginner in PHP & Symfony 3 and I have a problem: json_encode returns empty objects. You can check the image and code below.

/**
 * @Rest\Get("/user")
 */
public function getAction()
{
    $restresult = $this->getDoctrine()->getRepository('AppBundle:User')->findAll();
    if ($restresult === null) {
        return new View("there are no users exist", Response::HTTP_NOT_FOUND);
    }

    return new Response(json_encode($restresult), Response::HTTP_OK);
}

enter image description here

2 Answers
Related