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
10
votes
2 answers

Mixing route and query parameters using FOSRestBundle with Symfony

Using Symfony2 and FOSRestBundle I am attempting to implement API methods that have some number of fixed parameters defined in the route along with some optional parameters that may exist in the query string. For example: …
futureal
  • 3,025
  • 1
  • 22
  • 33
9
votes
2 answers

symfony2 FOSRestBundle annotations

Is anyone used put, get, post, delete annotations(https://github.com/FriendsOfSymfony/FOSRestBundle/blob/master/Controller/Annotations/) in controller. I'm trying to use it like this, but it still takes get methods. What is the purpose of those…
user257980
  • 1,059
  • 2
  • 15
  • 31
9
votes
2 answers

JMS Serializer Overriding Groups in FOSRestBundle

I read this article about overriding groups of child properties: use JMS\Serializer\SerializationContext; $context = SerializationContext::create()->setGroups(array( 'Default', // Serialize John's name 'manager_group', // Serialize John's…
StockBreak
  • 2,857
  • 1
  • 35
  • 61
9
votes
2 answers

How do you customize exception format with FOSRestBundle and Symfony 2?

I'm using FOSRestBundle with Symfony 2 to implement a REST API in JSON format. I want all API exceptions to be returned in a specific JSON format like this: { "success": false, "exception": { "exceptionClass": "SomeNastyException", …
Slava Fomin II
  • 26,865
  • 29
  • 124
  • 202
9
votes
4 answers

multipart/form-data and FormType validation

I am building an API using the FOSRestBundle and am at the stage where I need to implement the handling of the creation of new entities that contain binary data. Following the methods outlined on Sending binary data along with a REST API request …
Malachi
  • 33,142
  • 18
  • 63
  • 96
9
votes
2 answers

FOSRestBundle: routes and annotations for parameters

I'm able to get GET parameters with @QueryParam() annotation, but it looks like it works for Query String data only: /user?id=123. I'd prefer to have it like /user/123 instead. For this, I might use @Get("/user/{id}") annotation, but I don't see it…
Roman Newaza
  • 11,405
  • 11
  • 58
  • 89
9
votes
2 answers

JMS Serializer doesn't expose one property

I making a RESTful app with Symfony and FOSRestBundle. FOSRestBundle uses JMS Serializer to serialize data to json format. I have everything working with one little issue. This is my Entity class /** * Post * * @ORM\Table() *…
Gustek
  • 3,680
  • 2
  • 22
  • 36
8
votes
2 answers

Symfony REST file upload over PUT method

I have a REST service where I want to update a file over PUT. When I use POST I used the following to get the uploaded file: /** * @var Request $request */ $request->files->get('file'); How to get an uploaded file send as PUT in Symfony…
Alexander Schranz
  • 2,154
  • 2
  • 25
  • 42
8
votes
1 answer

NetBeans/Symfony2 gives "unused use statement" warnings when using FOSRestBundle namespaces

I have the following set up on my PC, Ubuntu: 13.10, NetBeans: 8.0, Symfony: 2.4.3, FOSRestBundle: 1.3.0, and I have a "false" warning "unused use statement" in my code: use FOS\RestBundle\Controller\Annotations; where later I have, /** /*…
d.chen
  • 134
  • 5
8
votes
2 answers

FosRestBundle post/put [create new/update entity] does not read Request correctly

long story short: Using FOSRestBundle I'm trying to create some entities via POST call, or modify existing via PUT. here the code: /** * Put action * @var Request $request * @var integer $id Id of the entity * @return View|array */ public…
rollsappletree
  • 620
  • 1
  • 5
  • 14
8
votes
4 answers

Symfony2 FOSRestBundle PUT Action FORM returns empty results

I am using Symfony 2.2 and the latest version of FOSRestBundle. So I have manage to make most of the actions work but I seem to have an issue with the FormBuilder that I am passing the Request of my PUT call in. I have checked the request object…
7
votes
2 answers

Symfony2 + FOS Rest Bundle - Regular route

I am developing an application using Symfony2 with fos-restbundle. I would like to create some API routes and also some regular routes (exactly one for AngularJS front-end). This is my fos_rest configuration (and a few configuration lines from…
probertgajda
  • 73
  • 1
  • 4
7
votes
3 answers

Every parent controller must have `get{SINGULAR}Action($id)` method when i have multi level sub resource in FOS Rest Bundle

I have three controller named BlogController, PostController, CommentController that CommentController is sub resource of PostController and PostController sub resource of BlogController. /** * @Rest\RouteResource("blog", pluralize=false) */ class…
ghanbari
  • 1,630
  • 1
  • 16
  • 31
7
votes
3 answers

Set up registration FOSUserBundle with FOSRestBundle REST API

Problem fixed, check my answer. I'm building a registration endpoint on my Symfony2.7 rest api. I am using FosRestBundle and FosUserBundle Here is the user model :
1
2
3
53 54