Questions tagged [fosrestbundle]

A Symfony 2 plugin by FriendsOfSymfony (FOS) which provides various tools to rapidly develop RESTful API's with Symfony 2.

A Symfony 2 bundle by FriendsOfSymfony (FOS) which provides various tools to rapidly developer RESTful API's with Symfony 2.

Its features include:

  • A View layer to enable output and format agnostic Controllers
  • A custom route loader to generate url's following REST conventions
  • Accept header format negotiation including handling for custom mime types
  • RESTful decoding of HTTP request body and Accept headers
  • Exception controller for sending appropriate HTTP status codes

Links:

803 questions
38
votes
3 answers

How to show null value in JSON in FOS Rest Bundle with JMS Serializer?

I had a read through this : https://github.com/schmittjoh/serializer/issues/77 but did not find any way to serialize null values in JSON for FOS Rest bundle with JMS serializer (meaning just show the key of the Doctrine object even if its null). I…
Geshan
  • 1,141
  • 2
  • 11
  • 21
37
votes
5 answers

How to display the symfony profiler for API request made in the browser?

I'm developing a REST api with Symfony2 + FOSRest bundle. I would like to know if there is any way for a call to the api in dev mode (app_dev.php) from the browser (corresponding to a Accept: text/html,application/xhtml+xml header) to display the…
Pyrech
  • 593
  • 1
  • 4
  • 14
21
votes
1 answer

CORS with Symfony, jQuery, FOSRestBundle and NelmioCorsBundle

⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️TL;DR: Edit (before reading the whole thing): This issue is solved because I made a very stupid mistake in my code, not related to CORS or anything. If you want to read this issue anyway, just note that it has a working…
Alex Rock
  • 831
  • 6
  • 26
17
votes
4 answers

Uploading image file through API using Symfony2 & FOSRESTBundle

I have been coding an API for a photo sharing app like Instagram using Symfony2, FOSRESTBundle, and Vichuploader for file uploads. I'm able to work around GET and POST requests, but I can't find an example of how to attach to a POST request, the…
MoonwalkerHN
  • 181
  • 1
  • 2
  • 4
16
votes
2 answers

How do routes in FOSRestBundle work?

Can someone clearly explain how routes are supposed to be configured for REST requests using FOSRest? Every tutorial seems to do it differently. My Controller:
user2142111
  • 161
  • 1
  • 1
  • 4
14
votes
5 answers

Symfony - validate empty query parameter values

I am using the FOSRestBundle and was wondering is it possible to validate against empty query parameters using annotations? For example when calling: /comments/1 an exception is thrown since both dealId and source query parameters haven't been…
Malachi
  • 33,142
  • 18
  • 63
  • 96
13
votes
4 answers

FOSRestBundle setup for return JSON but still asking for Twig template

I have configured FOSRestBundle as following: #FOSRestBundle fos_rest: param_fetcher_listener: true body_listener: true format_listener: rules: - { path: ^/, priorities: [ json, html ], fallback_format: ~,…
ReynierPM
  • 17,594
  • 53
  • 193
  • 363
12
votes
3 answers

Simple API Key Authentication in Symfony2 using FOSUserBundle (and HWIOauthBundle), filling in the gaps

Edit: See below for my own solution, which is, at the time of writing, functioning but imperfect. Would love some criticism and feedback, if I get something put together that I feel is really solid then I'll make a howto blog post for other people…
Pez
  • 1,251
  • 16
  • 32
11
votes
4 answers

FOSRestBundle doesn't work in Symfony 4.1

I have problem with returning views with FOSRestBundle working under Symfony 4.1 Project. This is code from my controller: class NewsController extends FOSRestController { public function getNewsAction() { $data = ['news1',…
symfonydevpl
  • 567
  • 1
  • 6
  • 20
11
votes
5 answers

JMS Serializer: how to use camel case for properties

I'm using FOS Rest bundle and JMS Serializer to create a REST Api. The problem is I would like to keep the property names in the JSON response camel cased instead of using _. For example, I have a property called employeeIdentifier, by default that…
petekaner
  • 8,071
  • 5
  • 29
  • 52
11
votes
3 answers

@RouteResource does not work

I'm using FosRestBundle and I'm declaring a controller with manually routes. namespace Cboujon\PropertyBundle\Controller; use FOS\RestBundle\Controller\Annotations\QueryParam; use FOS\RestBundle\Controller\Annotations\RouteResource; use…
Cristhian Boujon
  • 4,060
  • 13
  • 51
  • 90
11
votes
3 answers

How to specify default format for FOS\RestBundle to json?

My corresponding configuration is fos_rest: view: view_response_listener: force sensio_framework_extra: view: annotations: false and it really annoys to specify the route as @Route("/jobs", defaults={ "_format" = "json"…
zerkms
  • 249,484
  • 69
  • 436
  • 539
11
votes
4 answers

FOS rest bundle: unable to find template

I get the exception: Unable to find template "" The other similar questions didn't help; and weirdly enough it was working fine and then suddenly started giving me this exception. composer: "friendsofsymfony/rest-bundle": "0.13.*@dev", …
Tjorriemorrie
  • 16,818
  • 20
  • 89
  • 131
10
votes
2 answers

Symfony serializer - set circular reference global

Is there any way to set the circular reference limit in the serializer component of Symfony (not JMSSerializer) with any config or something like that? I have a REST Application with FOSRestBundle and some Entities that contain other entities which…
10
votes
1 answer

FOSRestBundle: How to remove {_format} parameter?

I need to support only single API format which is JSON and I don't like to {_format} in my routes. Is it possible to remove it?
Roman Newaza
  • 11,405
  • 11
  • 58
  • 89
1
2 3
53 54