- fixed being able to configure exception codes and messages based on interfaces (e.g.
Throwable)
- fixed the
ViewHandlerto not override an already setstatus_codein the serialization context - fixed embedding status codes in the response body when a mapping of exception classes to status codes is configured
- fixed handling requests without a content type inside the
RequestBodyParamConverter FlattenExceptionNormalizerdoes no longer implement theCacheableSupportsMethodInterfaceto ensure compatibility with older versions of the Symfony Serializer component
- added support for Symfony 5 compatibility
-
the route generation feature was removed, setting it to another value than
falseleads to an exception -
support for serializing exceptions was removed, setting the
fos_rest.exception.serialize_exceptionsoption to anything else thanfalseleads to an exception -
support for returning anything other than
stringornullfromresolve()when implementing theVersionResolverInterfacewas removed -
removed support for passing version numbers as integers to
Context::setVersion() -
removed the
isFormatTemplating(),renderTemplate(), andprepareTemplateParameters()methods from theViewHandlerclass and theViewHandlerInterface -
the constructor of the
ViewHandlerclass isprivatenow, use the staticcreate()factory method instead -
removed the
setTemplateVar(),setPopulateDefaultVars(),getTemplateVar(), andisPopulateDefaultVars()methods from theController\Annotations\Viewclass -
removed the
setEngine(),setTemplate(),setTemplateData(),setTemplateVar(),getEngine(),getTemplate(),getTemplateData(), andgetTemplateVar()methods from theView\Viewclass -
changed the default value of the
fos_rest.body_listeneroption tofalse -
removed the
setMaxDepth()/getMaxDepth()methods from theContextclass, useenableMaxDepth()/disableMaxDepth()instead -
dropped support for Symfony components < 4.4
-
removed the following options:
fos_rest.access_denied_listenerfos_rest.exception.exception_controllerfos_rest.exception.exception_listenerfos_rest.exception.servicefos_rest.service.inflectorfos_rest.service.routerfos_rest.service.templatingfos_rest.view.default_enginefos_rest.view.force_redirectsfos_rest.view.templating_formats
-
removed the following classes and interfaces:
FOS\RestBundle\Controller\Annotations\NamePrefixFOS\RestBundle\Controller\Annotations\NoRouteFOS\RestBundle\Controller\Annotations\PrefixFOS\RestBundle\Controller\Annotations\RouteResourceFOS\RestBundle\Controller\Annotations\VersionFOS\RestBundle\Controller\ExceptionControllerFOS\RestBundle\Controller\TemplatingExceptionControllerFOS\RestBundle\Controller\TwigExceptionControllerFOS\RestBundle\EventListener\AccessDeniedListenerFOS\RestBundle\EventListener\ExceptionListenerFOS\RestBundle\Inflector\DoctrineInflectorFOS\RestBundle\Inflector\InflectorInterfaceFOS\RestBundle\Routing\Loader\DirectoryRouteLoaderFOS\RestBundle\Routing\Loader\Reader\RestActionReaderFOS\RestBundle\Routing\Loader\Reader\RestControllerReaderFOS\RestBundle\Routing\Loader\RestRouteLoaderFOS\RestBundle\Routing\Loader\RestRouteProcessorFOS\RestBundle\Routing\Loader\RestXmlCollectionLoaderFOS\RestBundle\Routing\Loader\RestYamlCollectionLoaderFOS\RestBundle\Routing\ClassResourceInterfaceFOS\RestBundle\Routing\RestRouteCollectionFOS\RestBundle\Serializer\Normalizer\ExceptionHandlerFOS\RestBundle\Serializer\Normalizer\ExceptionNormalizer
-
removed the following services and aliases:
fos_rest.access_denied_listenerfos_rest.exception_listenerfos_rest.exception.controllerfos_rest.exception.twig_controllerfos_rest.inflectorfos_rest.routerfos_rest.routing.loader.controllerfos_rest.routing.loader.directoryfos_rest.routing.loader.processorfos_rest.routing.loader.reader.controllerfos_rest.routing.loader.reader.actionfos_rest.routing.loader.xml_collectionfos_rest.routing.loader.yaml_collectionfos_rest.serializer.exception_normalizer.jmsfos_rest.serializer.exception_normalizer.symfonyfos_rest.templating
-
the following classes are marked as
internal(backwards compatibility will no longer be guaranteed):FOS\RestBundle\DependencyInjection\Compiler\HandlerRegistryDecorationPassFOS\RestBundle\DependencyInjection\FOSRestExtensionFOS\RestBundle\Form\Extension\DisableCSRFExtensionFOS\RestBundle\Form\Transformer\EntityToIdObjectTransformerFOS\RestBundle\Normalizer\CamelKeysNormalizerFOS\RestBundle\Normalizer\CamelKeysNormalizerWithLeadingUnderscoreFOS\RestBundle\Serializer\Normalizer\FormErrorHandlerFOS\RestBundle\Serializer\Normalizer\FormErrorNormalizerFOS\RestBundle\Util\ExceptionValueMap
-
the following classes are now
final:FOS\RestBundle\Decoder\ContainerDecoderProviderFOS\RestBundle\Decoder\JsonDecoderFOS\RestBundle\Decoder\JsonToFormDecoderFOS\RestBundle\Decoder\XmlDecoderFOS\RestBundle\Form\Transformer\EntityToIdObjectTransformerFOS\RestBundle\Negotiation\FormatNegotiatorFOS\RestBundle\Request\ParamFetcherFOS\RestBundle\Request\ParamReaderFOS\RestBundle\Request\RequestBodyParamConverterFOS\RestBundle\Response\AllowMethodsLoader\AllowedMethodsRouterLoaderFOS\RestBundle\Serializer\JMSSerializerAdapterFOS\RestBundle\Serializer\SymfonySerializerAdapterFOS\RestBundle\Version\ChainVersionResolverFOS\RestBundle\Version\Resolver\HeaderVersionResolverFOS\RestBundle\Version\Resolver\MediaTypeVersionResolverFOS\RestBundle\Version\Resolver\QueryParameterVersionResolverFOS\RestBundle\View\JsonpHandlerFOS\RestBundle\View\ViewFOS\RestBundle\View\ViewHandler
- fixed being able to configure exception codes and messages based on interfaces (e.g.
Throwable)
- fixed the
ViewHandlerto not override an already setstatus_codein the serialization context - fixed embedding status codes in the response body when a mapping of exception classes to status codes is configured
- fixed handling requests without a content type inside the
RequestBodyParamConverter FlattenExceptionNormalizerdoes no longer implement theCacheableSupportsMethodInterfaceto ensure compatibility with older versions of the Symfony Serializer component
-
added a
SerializerErrorHandlerthat leverages theFOS\RestBundle\Serializer\Serializerinterface to hook into the error rendering process provided by the ErrorHandler component since Symfony 4.4 -
added a new normalizer (for the Symfony serializer) and a new handler (for the JMS serializer) to serialize
FlattenExceptioninstances, for backwards compatibility the resulting format by default is the same as was used for exceptions/errors before, use theflatten_exception_formatto opt-in to a format compatible with the API Problem spec (RFC 7807):fos_rest: exception: flatten_exception_format: 'rfc7807'
-
added a new
ResponseStatusCodeListenerthat maps exception/error codes to response status codes, enable it by setting the newmap_exception_codesoption totrue
-
the route generation feature is deprecated, disable it explicitly:
fos_rest: routing_loader: false
You need to configure your routes explicitly, e.g. using the Symfony Core annotations or the FOSRestBundle shortcuts like
FOS\RestBundle\Controller\Annotations\Get. You can usebin/console debug:router --show-controllersto help with the migration and compare routes before and after it. Change the routing loading:Before:
Acme\Controller\TestController: type: rest resource: Acme\Controller\TestControllerAfter:
Acme\Controller\TestController: type: annotation resource: Acme\Controller\TestControllerWhen using the Symfony Core route loading, route names might change as the FOSRestBundle used a different naming convention. Mind the
.{_format}suffix if you used thefos_rest.routing_loader.include_formatoption.In case you have OpenAPI/Swagger annotations, you can also use OpenAPI-Symfony-Routing which removes the need to have routing information duplicated. It also allows to add the
.{_format}suffix automatically as before.If migration to explicit routes is not possible or feasible, consider using RestRoutingBundle which extracted the auto-generation of routes in a BC way.
-
deprecated support for serializing exceptions, disable it by setting the
serialize_exceptionsoption to false:fos_rest: exception: serialize_exceptions: false
-
deprecated returning anything other than
stringornullfromresolve()when implementing theVersionResolverInterface. -
deprecated support for passing version numbers as integers to
Context::setVersion()(strings will be enforced as of 3.0) -
deprecated the
isFormatTemplating(),renderTemplate(), andprepareTemplateParameters()methods of theViewHandlerclass and theViewHandlerInterface -
deprecated the constructor of the
ViewHandlerclass, use the staticcreate()factory method instead -
deprecated the
setTemplateVar(),setPopulateDefaultVars(),getTemplateVar(), andisPopulateDefaultVars()methods of theController\Annotations\Viewclass -
deprecated the
setEngine(),setTemplate(),setTemplateData(),setTemplateVar(),getEngine(),getTemplate(),getTemplateData(), andgetTemplateVar()methods of theView\Viewclass -
deprecated not enabling the
fos_rest.body_listeneroption explicitly, it will be disabled by default in 3.0 -
deprecated the following options:
fos_rest.access_denied_listenerfos_rest.exception.exception_controllerfos_rest.exception.exception_listenerfos_rest.exception.servicefos_rest.service.inflectorfos_rest.service.routerfos_rest.service.templatingfos_rest.view.default_enginefos_rest.view.force_redirectsfos_rest.view.templating_formats
-
the following classes and interfaces are marked as
deprecated, they will be removed in 3.0:FOS\RestBundle\Controller\Annotations\NamePrefixFOS\RestBundle\Controller\Annotations\NoRouteFOS\RestBundle\Controller\Annotations\PrefixFOS\RestBundle\Controller\Annotations\RouteResourceFOS\RestBundle\Controller\Annotations\VersionFOS\RestBundle\Controller\ExceptionControllerFOS\RestBundle\Controller\TemplatingExceptionControllerFOS\RestBundle\Controller\TwigExceptionControllerFOS\RestBundle\EventListener\AccessDeniedListenerFOS\RestBundle\EventListener\ExceptionListenerFOS\RestBundle\Inflector\DoctrineInflectorFOS\RestBundle\Inflector\InflectorInterfaceFOS\RestBundle\Routing\Loader\DirectoryRouteLoaderFOS\RestBundle\Routing\Loader\Reader\RestActionReaderFOS\RestBundle\Routing\Loader\Reader\RestControllerReaderFOS\RestBundle\Routing\Loader\RestRouteLoaderFOS\RestBundle\Routing\Loader\RestRouteProcessorFOS\RestBundle\Routing\Loader\RestXmlCollectionLoaderFOS\RestBundle\Routing\Loader\RestYamlCollectionLoaderFOS\RestBundle\Routing\ClassResourceInterfaceFOS\RestBundle\Routing\RestRouteCollectionFOS\RestBundle\Serializer\Normalizer\ExceptionHandlerFOS\RestBundle\Serializer\Normalizer\ExceptionNormalizer
-
the following services and aliases are marked as
deprecated, they will be removed in 3.0:fos_rest.access_denied_listenerfos_rest.exception_listenerfos_rest.exception.controllerfos_rest.exception.twig_controllerfos_rest.inflectorfos_rest.routerfos_rest.routing.loader.controllerfos_rest.routing.loader.directoryfos_rest.routing.loader.processorfos_rest.routing.loader.reader.controllerfos_rest.routing.loader.reader.actionfos_rest.routing.loader.xml_collectionfos_rest.routing.loader.yaml_collectionfos_rest.serializer.exception_normalizer.jmsfos_rest.serializer.exception_normalizer.symfonyfos_rest.templating
-
the following classes are marked as
internal(backwards compatibility will no longer be guaranteed starting with FOSRestBundle 3.0):FOS\RestBundle\DependencyInjection\Compiler\HandlerRegistryDecorationPassFOS\RestBundle\DependencyInjection\FOSRestExtensionFOS\RestBundle\Form\Extension\DisableCSRFExtensionFOS\RestBundle\Form\Transformer\EntityToIdObjectTransformerFOS\RestBundle\Normalizer\CamelKeysNormalizerFOS\RestBundle\Normalizer\CamelKeysNormalizerWithLeadingUnderscoreFOS\RestBundle\Serializer\Normalizer\FormErrorHandlerFOS\RestBundle\Serializer\Normalizer\FormErrorNormalizerFOS\RestBundle\Util\ExceptionValueMap
-
the following classes are marked as
final(extending them will not be supported as of 3.0):FOS\RestBundle\Decoder\ContainerDecoderProviderFOS\RestBundle\Decoder\JsonDecoderFOS\RestBundle\Decoder\JsonToFormDecoderFOS\RestBundle\Decoder\XmlDecoderFOS\RestBundle\Form\Transformer\EntityToIdObjectTransformerFOS\RestBundle\Negotiation\FormatNegotiatorFOS\RestBundle\Request\ParamFetcherFOS\RestBundle\Request\ParamReaderFOS\RestBundle\Request\RequestBodyParamConverterFOS\RestBundle\Response\AllowMethodsLoader\AllowedMethodsRouterLoaderFOS\RestBundle\Serializer\JMSSerializerAdapterFOS\RestBundle\Serializer\SymfonySerializerAdapterFOS\RestBundle\Version\ChainVersionResolverFOS\RestBundle\Version\Resolver\HeaderVersionResolverFOS\RestBundle\Version\Resolver\MediaTypeVersionResolverFOS\RestBundle\Version\Resolver\QueryParameterVersionResolverFOS\RestBundle\View\JsonpHandlerFOS\RestBundle\View\ViewFOS\RestBundle\View\ViewHandler
- fixed compatibility with JMS Serializer with explicitly disabled max depth checks (#2060)
- fixed config validation when mapping
Throwableinstances of classes that do not extend PHP'sExceptionclass (#2131)
- harden the
JsonToFormDecoderto not error on non-array input (#2145)
- fixed serializing Error instances when the Symfony Serializer is used (#2110)
- fixed serializing Error instances when JMS Serializer is used (#2105)
- fixed compatibility with
nullowner returned by SensioFrameworkExtraBundle (#2097) - completely fixed handling
Throwableobjects inExceptionController::showAction(), continues #2093 (#2096)
- fixed handling all
Throwableobjects inExceptionController::showAction()(#2093) - fixed
ViewHandlerInterfacealias definition (#2085)
- ignore
SessionInterfaceandUserInterfacecontroller action arguments - fixed
ExceptionListenerdeprecation warning - fixed
ControllerNameParserdeprecation warning - fixed
DisableCSRFExtension::getExtendedTypes()return type - improved
EngineInterfaceerror message inViewHandler - improved Symfony 4.4 compatibility
- automatically use Twig as templating engine when available
- ensure compatibility with the
FlattenExceptionfrom the new ErrorRenderer component - fix handling the
serialize_nulloption with the Symfony serializer - added support for using multiple constraints for the
requirementsoption of the@RequestParamannotation - drop support for PHP 5.5, 5.6 and 7.0
- drop support for SF 4.0, 4.1 and 4.2 (3.4 LTS is still supported)
- deprecated using the
ParamFetcherclass without passing a validator as the third argument, this argument will become mandatory in 3.0 - fix compatiblity without the deprecated templating in Symfony 4.3; see #2012 on how to configure the FOSRestBundle
- removed symfony/templating from the dependencies; if you still use it you need to require it in your app
- compatibility with Symfony 4.2
- deprecated the
FOSRestControllerbase class, use the newAbstractFOSRestControllerinstead - dropped support for Symfony 2.7 to 3.3
- compatibility with JMS Serializer 2 and JMSSerializerBundle 3
- overwrite rules when they are defined in different config files instead of throwing exceptions
- fixed using the
nullableoption of the param annotations when themapoption is enabled - ensure a predictable order of routes by sorting controllers by name when loading classes from a directory
- reset the internal state of the view handler to fix compatibility with PHP-PM
- fix different bugs related to the handling of API versions (see #1491, #1529, #1691)
- [BC BREAK] The
@Routeannotation and all its children no longer extend SensioFrameworkExtraBundle's annotation. The main effect is that@Route::$serviceis no longer available. Instead, define your controllers using the FQCN as service IDs or create an alias in the container using the FQCN.
-
improved Symfony 4 compatibility
-
manually decorate the core JMS handler registry
-
run checks after SensioFrameworkExtraBundle
-
made the view handler alias public
-
check for definitions before they might be removed
-
added Yaml routing resource support
-
refactored several unit tests
-
added support for file paths to the directory route loader
-
added support for context factories when using JMS Serializer
-
the
RequestBodyParamConverterignores unrelated controller arguments to not conflict with Symfony's built-in argument resolver -
made the bundle compatible with SensioFrameworkExtraBundle 4.x
-
added some interface aliases to support by ID autowiring
-
added support for custom keys for groups when using JMSSerializerBundle
-
allow to load FOSRestBundle inside the kernel before JMSSerializerBundle
-
added the
fos_rest.routing_loader.prefix_methodsoption to disable method name prefixes in generated route names -
removed newline characters from exception messages
-
added a new
InvalidParameterExceptionas a specialization of theBadRequestHttpException -
deprecated the
FOS\RestBundle\Util\ViolationFormatterclass and theFOS\RestBundle\Util\ViolationFormatterInterface -
deprecated the
ViolationFormatterInterfaceargument of theParamFetcherclass constructor -
deprecated the
RedirectViewandRouteRedirectViewclasses, useView::createRedirect()andView::createRouteRedirect()instead -
added a
fos_rest.exception.debugconfig option that defaults to thekernel.debugcontainer parameter and can be turned on to include the caught exception message in the exception controller's response -
introduced the concept of REST zones which makes it possible to disable all REST listeners when a request matches certain attributes
-
fixed that serialization groups are always passed to the constructor as an array
-
added annotations to support additional HTTP methods defined by RFC 2518 (WebDAV)
-
added a new loader that allows to extract REST routes from all controller classes from a directory
-
introduced a serializer adapter layer to ease the integration of custom serialization implementations
-
deprecated the getter methods of the
ViewHandlerclass -
fixed an issue that prevented decoration of the
TemplateReferenceInterfacefrom the Symfony Templating component -
fixed: no longer overwrite an explicitly configured template in the view response listener
-
added support for API versioning in URL parameters, the
Acceptheader or using a custom header -
marked some classes and methods as internal, do no longer use them in your code as they are likely to be removed in future releases
-
deprecated the
DoctrineInflectorclass and theInflectorInterfacefrom theFOS\RestBundle\Util\Inflectorin favor of their replacements in theFOS\RestBundle\Inflectornamespace -
deprecated the
FormatNegotiatorclass and theFormatNegotiatorInterfacefrom theFOS\RestBundle\Utilnamespace in favor of the newFOS\RestBundle\Negotiation\FormatNegotiatorclass -
deprecated the
FOS\RestBundle\Util\MediaTypeNegotiatorInterfacewhich should no longer be used
-
handle
\Throwableinstances in theExceptionController -
fixed that the default exclusion strategy groups for the serializer are not the empty string
-
fixed a BC break that prevented the
CamelKeysNormalizerfrom removing leading underscores -
fixed the
AllowedMethodsRouteLoaderto work with Symfony 3.0
-
removed uses of the reflection API in favor of faster solutions when possible
-
fixed the configuration to use serialization groups and versions at the same time
-
when using Symfony 3.x, the bundle doesn't call methods anymore that have been deprecated in Symfony 2.x and were removed in Symfony 3.0
-
the
ViewResponseListenerdoes not overwrite explicitly configured templates anymore -
fixed the
ParamFetcherclass to properly handle sub requests
- added a
CamelKeysNormalizerWithLeadingUnderscorethat keeps leading underscores when converting snake case to camel case (for example, leaving_usernameunchanged)
CAUTION: Accidentally, this patch release was never published.
- removed some code from the
ViewResponseListenerclass that was already present in the parentTemplateListenerclass
-
made it possible to use the bundle with Symfony 3.x and fixed some compatibility issues with Symfony 3.0
-
fixed the exception controller to return a 406 (Not Acceptable) response when the format negotiator throws an exception
-
fixed loading XML schema definition files in case the paths contain special characters (like spaces)
-
return the FQCN in the form type extension's
getExtendedType()method to be compatible with Symfony >= 2.8 -
added the
extended-typeattribute to theform.type_extensiontag to be compatible with Symfony >= 2.8 -
fixed some code examples in the documentation
-
fixed exception message when using non-numeric identifiers (like UUID or GUID)
-
allow version 1.x of
jms/serializerandjms/serializer-bundle -
allow to use the Symfony serializer even if the JMS serializer is present
- fix regression when handling methods in
@Routeannotations