In Symfony how to work with Rest?

You want to work with the api in Symfony 4. It is only necessary to obtain the data, no update, delete.
Buy Libu DoctrineRestDriver to work with rest APIs as a base. Any other serious decisions are not met in Symfony. Examine the frame and don't know many solutions.

In my case the format of the api responses do not coincide with the proposed in DoctrineRestDriver. Instead of conventional body has meta and data. Data already stored in the answer itself. After reviewing Libu I realized that it can somehow customize the behavior of the parser. Everything inside is tightly made and does not substitute for classes.
In the issues of the project is the question: what to do if the format of the response and request are different. There answer is that Liba is not designed for this. Apparently, someone did not come along.

I can make a fork and add support for interfaces. Or even just to rewrite Libu for themselves. Perhaps as something in the frame to override the class. But not sure if I should follow that path. Too much is not suitable to solve my problem. What if you do make a small layer with the use of conditional and gazzle in the repositories to make calls?
March 19th 20 at 08:45
1 answer
March 19th 20 at 08:47
Want API to work through docrine?

Take a look at and an example implementation

Yes, you have to realize some things, but you won't depend on arrived nails formats offer DoctrineRestDriver

But only does this make sense?

If you need to implement a "mixed" entity, for example, you have Product and Product data that are in the API is the ideal solution to implement the loading of data on doctrinism postLoad event.

Desired objects rather than raw data from the API? View in the direction of the same or simonovskogo JMS serializer, which is enough in most cases.

But this is justified in that case, if you really need to put the API under doctrines abstraction...

> What if you do make a small layer with the use of conditional and gazzle in the repositories to make calls?

Found my implementation in real projects - in 99% of cases do. (In some - unfortunately, some fortunately, because it's very easy to maintain)
Yes, I do.
The examples looked at, it seems that it will be able to make your own version based on them. Serializer took note.

Don't see other options other than doctrine, although I do not like the fact that the doctrine is designed for the work with the base, and we have to work with the rest.
The API has pagination. There are search fields which are not present in the response and all that. But it will be read-only without saving. I would also like some of the responses to cache.

I already had a project with yii2 where we had to work with the api, but my. And I already was worn out. Did repositories, entities, etc. Hoping that Symfony has invented a silver bullet)) - freddy.Brak commented on March 19th 20 at 08:50

Find more questions by tags Symfony