Symfony 2 Doctrine export to JSON

后端 未结 3 485
一生所求
一生所求 2021-01-18 12:15

I\'m using Symfony 2 with Doctrine 2 to create a web service(JSON) for an iOS app.

To fetch my entity i do:

$articles = $this->getDoctrine()->g         


        
3条回答
  •  后悔当初
    2021-01-18 13:00

    You can use json_encode($articles) when you entity (or any other object) implements JsonSerializable:

     $this->getName(),
                'description' => $this->getDescription(),
            ];
        }
    }
    

提交回复
热议问题