3

I'm trying to integrate FOSRestBundle into my application.

I want to use it only when a route matches like ^/api.

I really don't know how to use this bundle, and i think the documentation is pretty bad. (No offense).

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

When i request any route from my browser, i get this error:

No matching accepted Response format could be determined

I just want to match the routes starting with ^/api.

Any ideas?

Canser Yanbakan
  • 3,780
  • 3
  • 39
  • 65

1 Answers1

5

You need to use zones feature:

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

read more about it in official docs: http://symfony.com/doc/master/bundles/FOSRestBundle/3-listener-support.html#zone-listener

Paweł Mikołajczuk
  • 3,692
  • 25
  • 32