FOSRest 包未找到操作路径
FOSRest bundle not found route for action
我尝试使用 FOSRestBundle 但出现错误:
No route found for "GET /en/users"
这是控制器动作:
public function getUsersAction()
{
return new Response('resting');
}
这里是 app/config/routin.yml 中的配置:
geekhub_main:
resource: "@GeekhubMainBundle/Resources/config/routing.yml"
prefix: /{_locale}
requirements:
_locale: |uk|en
defaults: { _locale: en }
这里是MainBundle/Resources/config/routing.yml
中的配置
users:
type: rest
resource: Geekhub\MainBundle\Controller\UsersController
这是其余的配置:
fos_rest:
format_listener: true
routing_loader:
default_format: json
view:
view_response_listener: true
formats:
json: true
xml: true
yml: true
路由调试显示:
get_users GET ANY ANY /{_locale}/users.{_format}
get_user GET ANY ANY /{_locale}/users/{slug}.{_format}
我做错了什么?
您不需要包含您的格式吗?所以 /en/users.json
?
我尝试使用 FOSRestBundle 但出现错误:
No route found for "GET /en/users"
这是控制器动作:
public function getUsersAction()
{
return new Response('resting');
}
这里是 app/config/routin.yml 中的配置:
geekhub_main:
resource: "@GeekhubMainBundle/Resources/config/routing.yml"
prefix: /{_locale}
requirements:
_locale: |uk|en
defaults: { _locale: en }
这里是MainBundle/Resources/config/routing.yml
中的配置users:
type: rest
resource: Geekhub\MainBundle\Controller\UsersController
这是其余的配置:
fos_rest:
format_listener: true
routing_loader:
default_format: json
view:
view_response_listener: true
formats:
json: true
xml: true
yml: true
路由调试显示:
get_users GET ANY ANY /{_locale}/users.{_format}
get_user GET ANY ANY /{_locale}/users/{slug}.{_format}
我做错了什么?
您不需要包含您的格式吗?所以 /en/users.json
?