W
W
wittyrider2015-09-06 17:01:51
symfony
wittyrider, 2015-09-06 17:01:51

FOSRestBundle how to make it work with symfony/serializer?

serializationGroups not working.
Controller:

/**
     * @Route("/", name="homepage")
     * @FOS\View(serializerGroups={"registration"})
     */
    public function indexAction()
    {
        return $this->get('app.user_repository')->findAll();
    }

Mistake:
Attempted to load class \"SerializationContext\" from namespace \"JMS\\Serializer\".\nDid you forget a \"use\" statement for another namespace?

It is clear that he uses the SerializationContext from JMS\Serializezr, but it is not clear why he does not use the standard serializer.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey, 2015-09-06
@wittyrider

https://github.com/FriendsOfSymfony/FOSRestBundle/...
TL;DR
symfony/serializer started supporting serialization groups only from version 2.7, before that only jms serializer could do this. Therefore, fosrest simply does not yet know how to use symfony / serializer for these purposes. Alas, adding full support for symfony/serializer will lead to rather sad BC-breaks and we will only see its full support in FOSRestBundle 2.0.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question