2018-03-23 14:51
浏览 68

API REST php7 symfony 3.4 - Databind json到表单

I found this: "How to process nested json with FOSRestBundle and Symfony forms" but the acepted reply was: "making an unmapped form and binding data manually using a form event"

In play, you can write your own data binder but for most formats(xml, json, ...), you can take the data automatically based on the Content-Type http header (the @BodyParser.Of(BodyParser.Json.class) is not mandatory here to get it working), there are some well know data binders available(from Spring or wherever). A product can have a list of items, and even so, you can bind the request body to a form automatically.

PHP/Symfony no learn yet how to solve this issue? If I create an API REST in php + symfonmy I need to write some kind of "parser" like this? Can some one share a link to a post or an example with a solution to this?

PD: I use the play example because I am not an experienced web developer(less in PHP), so take this like my mcve.

Thanks in advance.

图片转代码服务由CSDN问答提供 功能建议


播放,你可以写您自己的数据绑定器但对于大多数格式( xml json ,...),您可以获取数据 自动基于 Content-Type http标头( @ BodyParser.Of(BodyParser.Json.class)不是必需的这里让它工作),有一些熟知的数据绑定器可用(从Spring或任何地方)。 产品可以包含商品清单 ,即便如此,您可以绑定请求 自动生成一个表单

PHP / Symfony还没有学到如何解决这个问题? 如果我在php + symfonmy中创建一个API REST我需要写一些 “解析器”如这个? 是否有人可以分享链接到帖子或示例以及解决方案?



  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

2条回答 默认 最新

相关推荐 更多相似问题