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

Symfony2 + FOSRestBundle: Enable/disable REST functionality per controller/action?

A part of my application will be available as an API, so some of my pages needs to be available in JSON or XML (based on the Accept header 'Content Type'). I've used the FOSRestBundle and it works very well, but now ALL my pages are available in XML…
Jeff Maes
  • 707
  • 8
  • 13
4
votes
1 answer

Symfony "fos_rest.request_body" converter: do not deserialize nested DTO classes

I have a OrderDto class with a nested PointDto class (array of points): class OrderDto { /** * @var PointDto[] * @Assert\All({ * @Assert\Type("App\Dto\PointDto") * }) * @Assert\Valid() */ private array…
inkrot
  • 448
  • 5
  • 12
4
votes
2 answers

FOSRestBundle 2.4 | How to load rest type route

I upgraded my FOSUserBundle to 2.4 from 2.1 while I was upgrading my project to Symfony 3.4 from 2.8. With the same code that worked before, and this yml file: # app/config/routing.yml api_request_backend: type: rest prefix: /api …
NicolaPez
  • 567
  • 1
  • 4
  • 27
4
votes
2 answers

Doctrine doesn't set parent reference in child entity created through API POST

The situation We're developing a REST API built on Symfony 3 with Doctrine and FOSRestBundle, using JMS for entity (de)serialisation. The problem arises during a POST action, where we create a new entity (Team) with a collection of new child…
4
votes
2 answers

Symfony and Wildurand/Hateoas Bundle - no links on JSON reposnse

I am using FOSRest and Willdurand/Hateoas bundle. I follow examples from https://github.com/willdurand/Hateoas#configuring-links but there is no "links" field on JSON response. /** * Users * * @ORM\Table(name="users") * @ORM\Entity *…
Stevan Tosic
  • 6,561
  • 10
  • 55
  • 110
4
votes
0 answers

getUser return null in controller

I have a problem on a project. I use symfony 2.8, sonata-admin, fosuserbundle, fosrestbundle and lexikjwtauthbundle. On this route /api/login_check I can easily generate a token with a existing fosuser. But the problem is when I want to getUser in…
4
votes
6 answers

How to pass options to json_encode function in Symfony Serializer component

here is the situation: I work on a rest api, based on symfony3, it uses FOSRestBundle and symfony serializer component, so methods return array and FOSRest handles encoding and response. The problem is serializer use json_encode with default…
tarasikarius
  • 523
  • 6
  • 13
4
votes
1 answer

How to configure FOSRestBundle to not interfere with Custom Exception Controller

I have just updated my Symfony 2.7 page to 2.8. Beside Symfony itself a number of other packages have been updated as well. FOSRestBundle has been updated from version 1.4 to 2.1. After the update the CustomExceptionController I configured for Twig…
Andrei Herford
  • 17,570
  • 19
  • 91
  • 225
4
votes
1 answer

FOSRestBundle custom view handler not registering

I'm trying to create custom handler for serializing response into csv format. So far I've been following the steps from documentation (http://symfony.com/doc/master/bundles/FOSRestBundle/2-the-view-layer.html#custom-handler), however when calling my…
Nicolas
  • 1,256
  • 1
  • 10
  • 22
4
votes
1 answer

How to process nested json with FOSRestBundle and symfony forms

By nested json I mean something that keeps address data in its own "address" array: { "user": { "id": 999, "username": "xxxx", "email": "xxxx@example.org", "address": { "street": "13th avenue", "place": 12 } …
BartBiczBoży
  • 2,512
  • 2
  • 24
  • 33
4
votes
1 answer

How to not override original guzzle message

I am trying to create a three tier web application : Frontend (AngularJS) "API Exposure Layer" with Symfony2 and Guzzle (6) inspired by these slides by Meetic: http://www.slideshare.net/meeticTech/meetic-backend-mutation-with-symfony built with…
Purplefish32
  • 647
  • 1
  • 8
  • 24
4
votes
2 answers

FOSRestBundle forms

I am trying to build symfony2 rest api, but I am struggling with FOSRestBundle At first I could make work "@View()" annotation because it always would say that I template is missing, not matter what config options I would use I would get the same…
antanas_sepikas
  • 5,644
  • 4
  • 36
  • 67
4
votes
2 answers

Symfony2 FOSRESTBundle REST API to return PDF

I've made a Bundle and a REST controller inside. The "index" method return array in JSON-format, it's ok: MyBundle/Controller/Api/Rest/BaconController.php class BaconController extends Controller implements ClassResourceInterface { /** *…
dimaninc
  • 765
  • 5
  • 16
4
votes
2 answers

FOSRestBundle posting json data to a form not working

I am stack with posting JSON data to a form in the controller. The entity is not filled in with properties that I am sending, here it's how it looks like: // Controller class UserApiController extends FOSRestController { // works fine …
undefinedman
  • 620
  • 1
  • 11
  • 25
4
votes
1 answer

FOSRestBundle Controller as a service not working

I'm developing an api with symphony a fosrestbundle. I also want to use constructor injection in my controllers like I always do to inject some EntityRepository. The problem is that this injection is not working, I get an error that says that a…
danielrvt
  • 10,177
  • 20
  • 80
  • 121