fosrestbundle

How to add a general URI prefix to all routes of a controller with FOSRestBundle?

房东的猫 提交于 2019-12-11 01:58:04
问题 I have started to implement controllers for an application that is being developed with Symfony. This is my first attempt at using both Symfony and PHP at that task: I usually work with Java, together with either JAX-RS or Spring. I followed this tutorial. My test class is as follows and the URI /tags works as expected: namespace AppBundle\Controller; use FOS\RestBundle\Controller\Annotations as Rest; use FOS\RestBundle\Controller\FOSRestController; use Symfony\Component\HttpFoundation

FOSRestBundle How to validate the registration?

心已入冬 提交于 2019-12-09 23:29:27
问题 I'm developing a RESTFul API in Symfony 2.3.* with FOSUserBundle and FOSRestBundle, and I'm having trouble understanding how to create a registration method. My controller look like this : class UserRestController extends FOSRestController { //Other Methods ... public function postUserAction() { $userManager = $this->get('fos_user.user_manager'); $user = $userManager->createUser(); $param = $paramFetcher->all(); $form = $this->createForm(new UserType(), $user); $form->bind($param); if ($form-

@RouteResource does not work

安稳与你 提交于 2019-12-08 15:43:26
问题 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 FOS\RestBundle\View\View; use FOS\RestBundle\Controller\Annotations\Get; /** * Property controller. * @RouteResource("Property") */ class PropertyRESTController extends \FOS\RestBundle\Controller\FOSRestController { /** * * @return type * @Get("/types") * */

JMS Serializer serialize object in object with diffrent view

心不动则不痛 提交于 2019-12-08 08:19:42
问题 I'm developing a RESTful service with Symfony2, JMS Serializer Bundle, FOS Rest Bundle and Hateoas Bundle. There are 2 entities User and Company and I want to, when I serialize a Company get larger detail. But, when serializing User related Company show only Company ID and name object or just ID as integer. I have serialize policy like below. User Acme\UserBundle\Entity\User: exclusion_policy: ALL xml_root_name: user properties: id: expose: true type: integer company: expose: true type: Acme

How to process nested json with FOSRestBundle and symfony forms

ぃ、小莉子 提交于 2019-12-07 15:30:48
问题 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 } } } instead of flat one { "user": { "id": 999, "username": "xxxx", "email": "xxxx@example.org", "street": "13th avenue", "place": 12 } } Flat one is processed fine there using User entity and it's properties: "id", "username" and "email". It is nicely validated using symfony form feature:

The controller must return a response, array given

允我心安 提交于 2019-12-07 03:29:07
问题 I am trying to follow Will Durand's tutorial on how to set up a good REST API with Symfony2. However I am failing in the very beginning as I get this error: The controller must return a response (Array(welcome => Welcome to my API) given). Something basic must be wrong with my very basic configuration. I have tried different setting for the fos_rest config, but the configuration reference doesn't provide to be very helpful as I do not really understand what the single settings do. My setup: /

JMSSerializerBundle complex generated value

假装没事ソ 提交于 2019-12-07 02:35:48
问题 I need implement RESTful API for my site on symfony 2, so i use FOSRestBundle + JMSSerializerBundle I have such serializer yml for my entity: Acme\DemoBundle\Entity\Product: exclusion_policy: ALL accessor_order: custom custom_accessor_order: [id, title] properties: id: expose: true title: expose: true virtual_properties: getMainPhoto: serialized_name: photo The problem is that getMainPhoto return me url to full sized image. I want preprocess this url before sending response to api client

JMS Serializer serialize object in object with diffrent view

安稳与你 提交于 2019-12-06 17:26:10
I'm developing a RESTful service with Symfony2, JMS Serializer Bundle , FOS Rest Bundle and Hateoas Bundle . There are 2 entities User and Company and I want to, when I serialize a Company get larger detail. But, when serializing User related Company show only Company ID and name object or just ID as integer. I have serialize policy like below. User Acme\UserBundle\Entity\User: exclusion_policy: ALL xml_root_name: user properties: id: expose: true type: integer company: expose: true type: Acme\CompanyBundle\Entity\Company name: expose: true type: string surname: expose: true type: string

routing.yml import when using FOSRestBundle

六月ゝ 毕业季﹏ 提交于 2019-12-06 15:46:48
I follow tutorial in here ( http://npmasters.com/2012/11/25/Symfony2-Rest-FOSRestBundle.html ) about using FOSRestBundle. When setting up the route, I get error : Cannot import resource "D:\xampp\htdocs\SymRestTestApp\src\Per\RestBundle/Resources/config/routing.yml" from "D:/xampp/htdocs/SymRestTestApp/app/config\routing.yml". My app/config/routing.yml per_rest: resource: "@PerRestBundle/Controller" type: annotation prefix: / per: type: rest resource: "@PerRestBundle/Resources/config/routing.yml" My Per/RestBundle/Resources/config/routing.yml: organisation: type: rest resource: Per\RestBundle

symfony 2.7.13 JMS Serializer customization of 3rd-party bundles query problems

我只是一个虾纸丫 提交于 2019-12-06 11:09:39
I try to customize my jms serializer config and copy the xml config of SonataMediaBundle to my local config. The requests are in a Controller that extends FOSRestBundle in a Symfony 2.7.13 application with sonata-project bundles. My current issue is, that I have a very long execution time due to a pool of thousands queries. If I use the default serializer config of the sonataMediaBundle I only have one query. config.yml: jms_serializer: metadata: auto_detection: false directories: FOSUB: namespace_prefix: "FOS\\UserBundle" path: "%kernel.root_dir%/serializer/FOSUB" SonataMediaBundle: namespace