使用Symfony2,FOSRest和Doctrine构建API.鉴于以下路线:
"GET /api/path/to/product"
Run Code Online (Sandbox Code Playgroud)
以及以下参数:
[("vendorID", 10), ("destination", "tanzania"), ("type", "accommodation"), ("sort", "price", "ASC")]
Run Code Online (Sandbox Code Playgroud)
使用FOSRest捆绑包可以检索这些字符串,但是,将它们映射到学说查询是挑战的起因.
我想过使用为查询字符串的不同组合定制的大量案例语句,而不是优雅的解决方案.想要构建一个不会严重影响性能的更通用的控制器.任何建议都会有帮助.