gpt4 book ai didi

php - FOSRestBundle 捕获所有路由

转载 作者:可可西里 更新时间:2023-11-01 00:57:49 26 4
gpt4 key购买 nike

我正在尝试将 FOSRestBundle 集成到我的应用程序中。

我只想在路由匹配时使用它,如 ^/api

我真的不知道如何使用这个包,而且我认为文档非常糟糕。 (无意冒犯)。

fos_rest:
format_listener:
enabled: true
rules:
- { path: '^/api', priorities: ['json', 'xml'], fallback_format: 'html' }

当我从我的浏览器请求任何路由时,我得到这个错误:

No matching accepted Response format could be determined

我只想匹配以^/api开头的路由。

有什么想法吗?

最佳答案

您需要使用区域功能:

# app/config/config.yml
fos_rest:
zone:
- { path: ^/api/* }

在官方文档中阅读更多相关信息:http://symfony.com/doc/master/bundles/FOSRestBundle/3-listener-support.html#zone-listener

关于php - FOSRestBundle 捕获所有路由,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35943170/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com