Skip to content

Instantly share code, notes, and snippets.

@jgauthi
Last active September 15, 2021 15:43
Show Gist options
  • Save jgauthi/2c9feddf607addb1a7db7afe31ea39f9 to your computer and use it in GitHub Desktop.
Save jgauthi/2c9feddf607addb1a7db7afe31ea39f9 to your computer and use it in GitHub Desktop.
[Symfony] Example configuration bundle: Fos Rest
# config/packages/fos_rest.yaml
# Documentation: https://symfony.com/doc/master/bundles/FOSRestBundle/
fos_rest:
routing_loader: false
view:
view_response_listener: 'force'
formats:
json: true
xml: true
zone:
- { path: '^/api' }
format_listener:
rules:
- { path: '^/api/', priorities: ['json'], fallback_format: 'json', prefer_extension: false }
body_listener:
enabled: true
param_fetcher_listener:
enabled: true
serializer:
serialize_null: true
exception:
enabled: true
map_exception_codes: true
messages:
'Symfony\Component\HttpKernel\Exception\HttpException': true
'Symfony\Component\Security\Core\Exception\BadCredentialsException': true
codes:
'Symfony\Component\HttpKernel\Exception\NotFoundHttpException': 404
'Symfony\Component\Security\Core\Exception\BadCredentialsException': 401
'Symfony\Component\Security\Core\Exception\AccessDeniedException': 403
'LogicException': 500
'InvalidArgumentException': 400
'Exception': 400
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment