FOSRestBundle - allow only json + xml and default json if others requested

Can someone show me the link configuration of FOSRestBundle, which will allow json + xml and willd to default json if "Accepted" or "Content-Type" were not set.

My goal is to refuse support for html templates and all other unnecessary formats (in my case).

Thanks in advance!

+7
php symfony fosrestbundle
source share
1 answer

Got it.

# app/config/config.yml # ... fos_rest: routing_loader: default_format: json include_format: true param_fetcher_listener: force body_listener: true allowed_methods_listener: true view: view_response_listener: 'force' formats: json: true xml: true format_listener: rules: - { path: '^/api', priorities: ['json', 'xml'], fallback_format: json, prefer_extension: true } sensio_framework_extra: view: { annotations: false } router: { annotations: true } # ... 
+13
source share

All Articles