Answer the question
In order to leave comments, you need to log in
Why is fosrestbundle needed in symfony?
Good evening!
I used to write in Yii2. Now I want to write a REST application in symfony, I'm studying examples. All sorts of lessons and examples on the network are quite simple, somewhere JsonResponse is used, and somewhere the fosrestbundle additional library is used. But nowhere is it explained, what for is it needed, since it is possible to do everything with regular means? If it were not needed, it would not exist, but it is. Can you explain what it is for? When should it be used and when not?
Answer the question
In order to leave comments, you need to log in
FOSRestBundle simplifies the creation of REST endpoints by converting method names to routes + taking on a number of basic functions to simplify the creation of a REST API on Symfony. For example, you need to give normal responses in case of errors and exceptions, and errors, after all, are very different. It's unpleasant when you seem to have a REST API, and it suddenly starts rendering HTML.
In general, of course, all this can be done by hand, but in fact, in the end, something close will work out, well, maybe except for routing.
In general, FOSRestBundle is not very large, there are much more powerful solutions for creating APIs in the Symfony ecosystem.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question