Search code examples
restsymfonyroutesrestful-urlfosrestbundle

FOSRest bundle not found route for action


I try to use FOSRestBundle but gets error:

No route found for "GET /en/users"

Here is controller action:

public function getUsersAction()
{
    return new Response('resting');
}

Here is config in app/config/routin.yml:

geekhub_main:
  resource: "@GeekhubMainBundle/Resources/config/routing.yml"
  prefix:   /{_locale}
  requirements:
    _locale: |uk|en
  defaults: { _locale: en }

Here is config in MainBundle/Resources/config/routing.yml

users:
type:     rest
resource: Geekhub\MainBundle\Controller\UsersController

Here is config for the rest:

fos_rest:
format_listener: true
routing_loader:
    default_format: json
view:
    view_response_listener: true
    formats:
        json: true
        xml: true
        yml: true

Route debug display:

 get_users                GET    ANY    ANY  /{_locale}/users.{_format}                     
 get_user                 GET    ANY    ANY  /{_locale}/users/{slug}.{_format} 

What I am doing wrong ?


Solution

  • Do you not need to include your format? So /en/users.json?