I have problem with returning views with FOSRestBundle working under Symfony 4.1 Project.
This is code from my controller:
class NewsController extends
Do you send the Accept: application/json
in your request?
If not, you do not necessarily need twig
, but you need to remove html
from the format configuration in the bundle config:
fos_rest:
format_listener:
rules:
- { path: ^/, prefer_extension: true, fallback_format: json, priorities: [ json ] }
The default is to have html
in the priorities, and that requires twig
.