FAQ Database Discussion Community


Return a 'raw' response with FOSRestBundle

symfony2,fosrestbundle
I'm in a bit of a pickle and I hope one of the more advanced Symfony / FOSRestBundle users can help me out with this. FOSRestBundle returns responses as such: <?xml version="1.0" encoding="UTF-8"?> <result> <entry> </entry> </result> The thing is, I am storing complete XML blobs in my database because...

FOS Rest Bundle not returning proper json

php,rest,symfony2,facebook-php-sdk,fosrestbundle
As you can see, the 'cover' and 'parking' index are both arrays. But when i return the response I get something like this. The 'cover' and 'parking' key are both not showing values in the json response. So this is my controller: public function getPageInfoAction($page) { $request = (new...

Symfony FOSRestBundle POST request 500 error

php,symfony2,fosrestbundle
I'm trying to create an entity using FOSRestBundle. The URL: POST http://localhost:8000/app_dev.php/api/links The request payload: {"link":{"id":"5","title":"foo","description":"foo","url":"foo","image":null,"issue":"1","creator":"1"} } Here is the controller (genrated): /** * Create a Link entity. * * @View(statusCode=201, serializerEnableMaxDepthChecks=true) * * @param Request $request * * @return Response * */ public function postAction(Request $request) { $entity =...

How can I use a DataTransformer transform with the FosRestBundle view layer

symfony2,fosrestbundle
I've using a DataTransformer on my form to reverseTransform a decimal value send by the client into a Money/Money object. This works well as expected, however when I return the data to the client using the FosRestBundle view layer, I'm not sure how I can use that transformer to transform...

FOSrestBundle : Invalid configuration for path “fos_rest.param_fetcher_listener”

symfony2,fosrestbundle
My previous configuration of FOSrestBundle was working properly. I added HWIOAuthBundle, and now FOSrestBundle is throwing an error, even though I didn't modify its configuration. This is the error I get: Invalid configuration for path "fos_rest.param_fetcher_listener": The param_fetcher_listener option does not support {"enabled":true,"service":null}. Please choose one of [false,true,"force"] This is...

Is {0:{“id”:1,…},{“id:2,…}} a other reprensation of a JSON list like [{”id“:1,…},{”id:2,…}]

json,symfony2,dart,fosrestbundle
I have a little dilema. I have a backend/Frontend Application that comunicates with a JSON based REST Api. The backend is written in PHP(Symfony/jmsserializer) and the Frontend in Dart The communication between these two has a little Problem. For most List Data the backend responds with a JSON like [{"id":1,...},{"id:2,....}]...

FOSRest Symfony POST using json

json,symfony2,post,fosrestbundle
I'm new with the symfony framework. I'm trying to create webservices with FOSRest bundle but I had a problems when I tried to implement the POST method for one entity with json. Test: public function testJsonPostNewTesteAction(){ $this->client->request( 'POST', '/api/teste/new', array(), array(), array( 'Content-Type' => 'application/json', 'Accept' => 'application/json' ), '{"Teste":{"title":"O...

FOSRestBundle forms

forms,symfony2,fosrestbundle
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 error, then in my routing...

Symfony2 fos_rest_bundle param converter not calling entity constructor

php,symfony2,converter,fosrestbundle
I'm developing an API and have the following entity: /** * Solicitud de registro. * * @ORM\Table() * @ORM\Entity(repositoryClass="DnD\RaHApiBundle\Repository\ApplicationRepository") */ class Application { public function __construct() { $pending = new Event("PENDING", "APPLICATION"); $this->status = new ArrayCollection($pending); $this->ownsVehicle = false; $this->resident = true; $this->timestamp = new DateTime(); } /** * @var...

How to set proper JSON response for POST method in RESTful API from FOSRestBundle?

php,json,symfony2,fosrestbundle,symfony-2.6
I am making a POST method for a RESTful API. The API is built on top of FOSRestBundle and NelmioApiDoc as you may notice. I am not able to validate when file is not uploaded or when rid parameter is missing and response with proper JSON. This is what I...

How to return or display data in JSON format using FOSRestBundle

php,json,rest,symfony2,fosrestbundle
I am working in a Restful API using Symfony2 and FOSRestBundle. I have read view layer docs but is not clear to me how to handle output for API. What I want to achieve is simple: display or return or output the result as valid JSON. This is what I...

Doubts around Symfony2 Routing component usage

php,symfony2,fosrestbundle,symfony-routing
I'm setting up FOSRestBundle and have some doubts, don't know if related to Symfony2 Routing component or can be done in any other way. Here, 1) How do I check if X-PDONE-SESSION-ID is set on request headers before execute the method? Can this be done using annotations on routing? Any...

How to change post parameters to json raw format

php,rest,symfony2,fosrestbundle,symfony-2.6
I am using FOSRestBundle for build a Restful API. I have this code for a POST Restful service: /** * Create a new session. * @param ParamFetcher $paramFetcher * * @ApiDoc( * resource = true, * https = true, * description = "Create a new session", * statusCodes = {...

FOSRestBundle setup for return JSON but still asking for Twig template

php,json,symfony2,fosrestbundle,symfony-2.6
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: ~, prefer_extension: true } media_type: version_regex: '/(v|version)=(?P<version>[0-9\.]+)/' body_converter: enabled: true validate: true view: mime_types: json: ['application/json', 'application/json;version=1.0', 'application/json;version=1.1'] view_response_listener: 'force' formats: xml: false json: true templating_formats:...

Circular reference detected in routing_dev.yml

php,symfony2,fosrestbundle,symfony-routing,nelmio-api-doc
I'm getting crazy with this circular reference issue and I can't find what I'm doing wrong. This is the content of /app/config/routing.yml: pd_one: resource: "@PDOneBundle/Controller/" type: annotation prefix: / template: resource: "@TemplateBundle/Controller/" type: annotation prefix: / fos_user: prefix: /admin resource: "@FOSUserBundle/Resources/config/routing/all.xml" restful_services: resource: "@PDOneBundle/Resources/config/routing.yml" type: rest prefix: /api nelmio_apidoc: resource:...

Add a root element name using JMS Serializer with Symfony 2.6

symfony2,fosrestbundle,jmsserializerbundle,jms-serializer,symfony-2.6
I have implemented web services using Symfony 2.6 with FOSRestBundle and JMSSerializerBundle. I can't manage to have a root element named request eventhough I put xml_root_name: request in the configuration file. I have a config\serializer\Entity.Request.yml file with the following information: Tvjp\RequestBundle\Entity\Request: exclusion_policy: ALL xml_root_name: request properties: id: expose: true type:...

Symfony Request Object not being Injected in FosRest nested controller

symfony2,fosrestbundle
I'm having an issue with Symphony not injecting the Request object when specified in my controller, my code is as follows: Routing.yml: user: type: rest resource: AppBundle\Controller\UserController user_comments: type: rest parent: user resource: AppBundle\Controller\UserCommentsController And FosRest Controller namespace AppBundle\Controller; use Symfony\Component\HttpFoundation\Request; class UserCommentsController extends BaseRestController { public function postCommentAction(Request $request,...

Get dates in “human readable” format

php,symfony2,date,fosrestbundle
I am working in a RESTFul API using Symfony2 and FOSRestBundle. The entities use Gedmo for Timestampable options: use Gedmo\Timestampable\Traits\TimestampableEntity; And I get the createdAt as any other column: $obj->getCreatedAt() Then I pass that response to FOSRestBundle: $respEmail = [ "id" => (string)$entEmail->getId(), ... "category" => $entEmail->getEmailsCategory(), "createdAt" => $entEmail->getCreatedAt()...

Symfony2 FosRestBundle root api url

api,symfony2,namespaces,fosrestbundle
I've been looking at the FOS-Rest-Bundle documentation in order to develop an API of mine. The problem is that I would like the API to be under api/ and there doesn't seem to be any option to achieve this. Is there a way? how would I do this? Thanks...