0

I am currently building an API and it is a requirement to have the option to get the data in a CSV format. I want this to work in the same way as it works for 'xml'. By this i mean i need to be able to add '.csv' to the end of the URL and this would then return the results in a CSV format.

currently if i go to /entity/all.xml the serializer will set the format to xml

I cant seem to find where symfony is extracting this from the URL

So my question is if i go to /entity/all.csv how to i extract the csv from the url to set the format? How does the current serializer do it?

I understand that after this i will need to write the code to actually serialize the data but I'm struggling to work out how this part of the process will work.

I will apologize in advance for asking quite a vague question but Ive been stuck on this for a while now and no search has been able to help me(doesn't help that i don't really know how to word this in a search)

I have tried stepping though the code to see if i can find where its done but i cant seem to spot it plus there is quite a lot of code to step through :/

Neil
  • 766
  • 1
  • 8
  • 23
  • are you using fos rest bundle ? do you use `_format` for route ? – john Smith Jan 08 '16 at 11:12
  • I am using the FOS rest bundle yeah but Im am new to smfony 2 in general, the routes do have _format: on them e.g `defaults: { _controller: Bundle:Api/Entity/ApiEntity:all, _format: ~ }` – Neil Jan 08 '16 at 11:20
  • 1
    maybe this helps https://github.com/FriendsOfSymfony/FOSRestBundle/issues/869 – john Smith Jan 08 '16 at 11:23
  • Thank you very much, this is pretty much exactly what im looking for and from just scanning over it i can see this is going to help me loads! – Neil Jan 08 '16 at 11:26

0 Answers0