Search code examples
phpsymfonyfosrestbundle

Whether to use FOSRestBundle or just json_encode()?


I am creating an API with Symfony 2. I'm using FOSRestBundle for this. Since the bundle and json_encode() return the same result, why should I use the bundle?

Why shouldn't I use json_encode() to encode the array into JSON for returning the response?


Solution

  • why should i use the bundle?

    Well depends on what your requirements are. If you're trying to develop restful APIs or some fancy things like that you should definitely go with the bundle. If you're just trying to display some json data to the front end just go with a simple json_encode.