Symfony 8.1 is a minor release. According to the Symfony release process, there should be no significant
backward compatibility breaks. Minor backward compatibility breaks are prefixed in this document with
[BC BREAK], make sure your code is compatible with these entries before upgrading.
Read more about this in the Symfony documentation.
If you're upgrading from a version below 8.0, follow the 8.0 upgrade guide first.
- [BC BREAK] Add
objectsupport to input options and arguments' default by changing the$defaulttype tomixedinInputArgument,InputOption,#[Argument]and#[Option] - Add optional
$formatargument toSymfonyStyle::createProgressBar(),SymfonyStyle::progressStart(), andSymfonyStyle::progressIterate()to allow passing a customProgressBarformat string - Deprecate passing both
InputArgument::REQUIREDandInputArgument::OPTIONALmodes toInputArgumentconstructor - Deprecate passing more than one out of
InputOption::VALUE_NONE,InputOption::VALUE_REQUIREDandInputOption::VALUE_OPTIONALmodes toInputOptionconstructor
- Deprecate configuring options
alias,parent,synthetic,file,arguments,properties,configuratororcallswhen usingfrom_callable - Deprecate default index/priority methods when defining tagged locators/iterators; use the
#[AsTaggedItem]attribute instead - Deprecate named autowiring aliases that don't use
#[Target]use Symfony\Component\DependencyInjection\Attribute\Target; public function __construct( + #[Target] private StorageInterface $imageStorage, ) {
- Deprecate setting an
$aliasMapinRegisterMappingsPass. Namespace aliases are no longer supported in Doctrine.
- Always set
LIBXML_NONETinCrawler::addXmlContent()so external entities cannot trigger network requests
- Add argument
$deprecationsNamespacesMappingtoDebugClassLoader::enable()to configure namespace-to-vendor remapping for deprecation checks
- Deprecate passing boolean as the second argument of
ValidatorExtensionandFormTypeValidatorExtension's constructors; pass aViolationMapperInterfaceinstead - Add argument
$violationMappertoValidatorExtensionTraitandTypeTestCase'sgetExtensions()methods
- Deprecate calling
Filesystem::mirror()with optioncopy_on_windows, use optionfollow_symlinksinstead
-
Deprecate setting the
framework.profiler.collect_serializer_dataconfig option -
Deprecate the
framework.http_cache.terminate_on_cache_hitconfig option -
Deprecate parameters
router.request_context.schemeandrouter.request_context.host; use therouter.request_context.base_urlparameter or theframework.router.default_uriconfig option instead -
Deprecate setting
framework.http_client.default_options.caching.max_ttltonull, use a positive integer instead -
Deprecate
sendersnesting level for messenger routing config; use string or a list of strings instead -
Deprecate registering console commands by overriding
Bundle::registerCommands(), use the#[AsCommand]attribute or theconsole.commandservice tag instead -
Deprecate calling
FrameworkExtension::load()directly without first loadingServicesBundle's extension. Tests that wire up aContainerBuilderby hand should now do:+new ServicesBundle()->getContainerExtension()->load([], $container); new FrameworkExtension()->load($config, $container);For real kernels,
FrameworkBundlecarries a#[RequiredBundle(ServicesBundle::class)]attribute that should be processed already.
- Deprecate passing
nullas$maxTtltoCachingHttpClient, pass a positive integer instead
- Deprecate setting public properties of
RequestandResponseobjects directly; use setters or constructor arguments instead ParameterBag::getInt()andParameterBag::getBoolean()now throwUnexpectedValueExceptioninstead of silently returning0/falsewhen the value cannot be converted
-
Deprecate
BundleInterface, use the one from the DependencyInjection component instead -
Deprecate
MergeExtensionConfigurationPass, use the one from the DependencyInjection component instead -
Deprecate
FileLocator, use the one from the DependencyInjection component instead -
Deprecate
ServicesResetter,ServicesResetterInterface, andResettableServicePass, use the ones from the DependencyInjection component instead -
Deprecate passing a non-flat list of attributes to
Controller::setController() -
Deprecate the
Symfony\Component\HttpKernel\DependencyInjection\Extensionclass, use the parentSymfony\Component\DependencyInjection\Extension\Extensionclass instead:- use Symfony\Component\HttpKernel\DependencyInjection\Extension; + use Symfony\Component\DependencyInjection\Extension\Extension; class ExampleExtension extends Extension { // ... }
-
Deprecate passing a
ControllerArgumentsEventto theViewEventconstructor; pass aControllerArgumentsMetadatainstead -
Deprecate
Bundle::registerCommands(), use the#[AsCommand]attribute or theconsole.commandservice tag instead of overriding this method
- Serializers now return
Envelope<MessageDecodingFailedException>on decode failure instead of throwing; custom serializers that still throw are supported via a BC fallback in receivers - Receivers no longer delete messages from the queue on decode failure; they are routed through the normal retry/failure transport path instead
- Add argument
$fetchSizetoReceiverInterface::get()andQueueReceiverInterface::getFromQueues() - Deprecate
StopWorkerOnTimeLimitListenerin favor of using thetime_limitworker option - Add
forceRetry()method toRecoverableExceptionInterface
- Add
getParentRoleNames()method toRoleHierarchyInterface - Make
RoleHierarchyInterface::getReachableRoleNames()return roles as both keys and values - Deprecate
SameOriginCsrfTokenManager::onKernelResponse(),SameOriginCsrfTokenManager::clearCookies()andSameOriginCsrfTokenManager::persistStrategy(); this logic is now handled automatically bySameOriginCsrfListener - Deprecate passing the
$eraseCredentialsargument toAuthenticatorManager::__construct(), as theeraseCredentials()method was removed in Symfony 8.0
- Deprecate the
security.erase_credentialsconfig option and thesecurity.authentication.manager.erase_credentialscontainer parameter, as theeraseCredentials()method was removed in Symfony 8.0
- Deprecate datetime constructor as a fallback, in version 9.0 a
Symfony\Component\Serializer\Exception\NotNormalizableValueExceptionwill be thrown when a date could not be parsed using the default format - Change the signature of
PartialDenormalizationException::__construct($data, array $errors)to__construct(mixed $data, array $notNormalizableErrors, array $extraAttributesErrors = []) - Deprecate
PartialDenormalizationException::getErrors(), usegetNotNormalizableValueErrors()instead
- Add argument
$formattoUlid::isValid()
-
Deprecate
ConstraintValidatorInterface::initialize()andConstraintValidatorInterface::validate()in favor ofConstraintValidatorInterface::validateInContext(). TheConstraintValidatorabstract class handles the context management when extending it. When writing tests withConstraintValidatorTestCase, use the newvalidatemethod to abstract the way to use the constraint validator.Your code Action required extends ConstraintValidatorNothing to do implements ConstraintValidatorInterfacedirectlyImplement validateInContext()tests using ConstraintValidatorTestCaseCall $this->validate()instead of$this->validator->validate() -
Implementing
ConstraintViolationListInterfacewithout implementingfindByCodes()is deprecated
- Deprecate
HydratorandInstantiatorclasses, usedeepclone_hydrate()from the deepclone extension instead