fosrestbundle

FOSRestBundle : ParamFetcher error

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-20 06:13:01
问题 I'm Using FOSRestBundle for my project I've configured this route to have access to different kinf of data : ``` /** * @Rest\Get("") * * @Rest\QueryParam( * name="categoriesId", * requirements="[0-9a-zA-Z\- \/_:.,\s]", * default="", * description="The categories ids." * ) * @Rest\QueryParam( * name="orderBy", * requirements="[a-zA-Z0-9]", * default="score", * description="The keyword to search for." * ) * @Rest\QueryParam( * name="order", * requirements="asc|desc", * default="desc", *

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

本小妞迷上赌 提交于 2019-12-19 05:42:52
问题 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" }) every time. So is it possible to specify it somewhere to be assumed by default? PS: If I remove defaults={ "_format" = "json" } and call the /jobs endpoint I'm getting an exception Unable to find template "APIBundle:Jobs:post.html.twig". PPS: routing_loader: default_format:

Symfony2 App with RESTful authentication, using FOSRestBundle and FOSUserBundle

佐手、 提交于 2019-12-18 12:38:24
问题 I'm making REST API for my JS driven app. During login, the login form is submitted via AJAX to url /rest/login of my API. If the login is succesful, it returns 204 If it fails, it returns 401 While I have separated firewalls for the API and the app itself, they share the same context which should mean, that when user authenticates against the API, he's authenticated against the app too. So, when the server returns 204, page will reload and it should redirect user to the app, because he's now

Uploading image file through API using Symfony2 & FOSRESTBundle

情到浓时终转凉″ 提交于 2019-12-18 11:25:36
问题 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 actual image so that in my case, Vichuploader can grab it and help me out with the file upload. By the way, I can upload a file without issue using the stack mentioned through the use of a normal form. 回答1: I have been looking for a solution about the

FOSRestBundle & JMSSerializer : Wrong Json Response [closed]

一个人想着一个人 提交于 2019-12-13 09:37:16
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 5 years ago . In the same response i get a field as object and a field as Array, how can i correct this ? Note i don't controle the building of my response because i'm using JMSSerializer CODE (Edit 1) \Entity\Profil.php class Profil { ... /** * Get actualites * * @return \Doctrine\Common\Collections\Collection */ public

FOSRestBundle “avoid” Javascript eventListener

旧巷老猫 提交于 2019-12-13 03:44:46
问题 I am trying to create a simple CRUD application by using Symfony and AngularJs, My problem is as describe here: Trying to use $compileProvider, CRUD and bootstraped directive ng-clink failed When I m trying to load my template (the whole forms without compile) by using : {{ render(controler('App:getTemplate',{parameters})) }} when I try whithout rendering it work well and I need to change my template dynamically. My event listener does not apear over my angularJs diverctives, may this problem

CSRF token is invalid when calling rest post api from php Client

安稳与你 提交于 2019-12-13 01:26:37
问题 I have created a rest api in Symfony. It uses form for the client to send the data. I have used 'csrf_protection' => false in setDefaultOptions, but still getting the error The CSRF token is invalid. Please try to resubmit the form 回答1: Did you test your api over NelmioApiDocBundle sanbox, or your sending data from form on frontned side? Are you sure that your not sending csrf_protection requsest parameter to your api? 来源: https://stackoverflow.com/questions/19344272/csrf-token-is-invalid

Fosrestbundle body empty when multipart request

白昼怎懂夜的黑 提交于 2019-12-12 14:57:23
问题 In the code bellow I expect the $request->getContents() to get the body content of the HTTP request. When sending non multipart request this works as expected though when using multipart requests the $body variable remains empty. public function postDebugAction(Request $request) { $body = $request->getContent(); if (empty($body)) { throw new \Exception('Body empty.'); } return $this->view(array(), 201); } After reading this question and answer I added a body listener aswell. <?php namespace

FOSRestBundle custom view handler not registering

故事扮演 提交于 2019-12-12 13:29:20
问题 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 endpoint with .csv extension I still get the error: The format "csv" is not supported for serialization. Here's my services.yml config bit: api.csv_handler: class: ApiBundle\ViewHandlers\CsvViewHandler api.view_handler: parent: fos_rest.view

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

只愿长相守 提交于 2019-12-12 11:38:56
问题 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 * @Serializer\ExclusionPolicy("ALL") * @Hateoas\Relation("self", href="expr('/users' ~ object.getId())") */ class User { /** * @var integer * * @ORM\Column(name="id", type="integer") * @ORM\Id * @ORM\GeneratedValue(strategy="IDENTITY") * @Serializer\Groups({