Skip to content

Serializer example with Doctrine Entity #2225

Closed
@gkatsanos

Description

@gkatsanos

Hello,
I was trying to make a doctrine entity -> json conversion work with the Serializer bundle, I was following both http://symfony.com/doc/current/components/serializer.html and http://jmsyst.com/libs/serializer#usage . The code mentions several times this:
$serializer->serialize($person, 'json'); or more generally, this: $serializer->serialize($data, 'json'); .
It seems that in order for it to work, you need to
$avariable = $serializer->serialize($data, 'json'); and return that $avariable in the response.
I understand it might seem trivial for PHP-ers but as it's a guide for people starting up, why not add a line with the proper return response? (would save time:))
Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    actionableClear and specific issues ready for anyone to take them.bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions