- The
Client::submit()method will have a new$serverParametersargument in version 5.0, not defining it is deprecated.
- Deprecated
CacheItem::getPreviousTags(), useCacheItem::getMetadata()instead.
-
Deprecated constructing a
TreeBuilderwithout passing root node information:Before:
$treeBuilder = new TreeBuilder(); $rootNode = $treeBuilder->root('my_config');
After:
$treeBuilder = new TreeBuilder('my_config'); $rootNode = $treeBuilder->getRootNode();
-
Deprecated
FileLoaderLoadException, useLoaderLoadExceptioninstead.
-
Deprecated passing a command as a string to
ProcessHelper::run(), pass the command as an array of arguments instead.Before:
$processHelper->run($output, 'ls -l');
After:
$processHelper->run($output, array('ls', '-l')); // alternatively, when a shell wrapper is required $processHelper->run($output, Process::fromShellCommandline('ls -l'));
- The
lazyattribute ondoctrine.event_listenertags was removed. Listeners are now lazy by default. So anylazyattributes can safely be removed from those tags.
- The
Crawler::children()method will have a new$selectorargument in version 5.0, not defining it is deprecated.
- The
Finder::sortByName()method will have a new$useNaturalSortargument in version 5.0, not defining it is deprecated.
-
The
symfony/translationdependency has been removed - runcomposer require symfony/translationif you need the component -
The
getExtendedType()method of theFormTypeExtensionInterfaceis deprecated and will be removed in 5.0. Type extensions must implement the staticgetExtendedTypes()method instead and return an iterable of extended types.Before:
class FooTypeExtension extends AbstractTypeExtension { public function getExtendedType() { return FormType::class; } // ... }
After:
class FooTypeExtension extends AbstractTypeExtension { public static function getExtendedTypes(): iterable { return array(FormType::class); } // ... }
-
The
scaleoption of theIntegerTypeis deprecated. -
The
$scaleargument of theIntegerToLocalizedStringTransformeris deprecated. -
Deprecated calling
FormRenderer::searchAndRenderBlockfor fields which were already rendered. Instead of expecting such calls to return empty strings, check if the field has already been rendered.Before:
{% for field in fieldsWithPotentialDuplicates %} {{ form_widget(field) }} {% endfor %}After:
{% for field in fieldsWithPotentialDuplicates if not field.rendered %} {{ form_widget(field) }} {% endfor %} -
The
regionsoption of theTimezoneTypeis deprecated.
-
The following middleware service ids were renamed:
messenger.middleware.call_message_handlerbecomesmessenger.middleware.handle_messagemessenger.middleware.route_messagesbecomesmessenger.middleware.send_message
If you set
framework.messenger.buses.[bus_id].default_middlewaretofalse, replace any of these names in theframework.messenger.buses.[bus_id].middlewarelist. -
The
allow_no_handlermiddleware has been removed. Useframework.messenger.buses.[bus_id].default_middlewareinstead:Before:
framework: messenger: buses: messenger.bus.events: middleware: - allow_no_handler
After:
framework: messenger: buses: messenger.bus.events: default_middleware: allow_no_handlers
-
The
messenger:consume-messagescommand expects a mandatory--busoption value if you have more than one bus configured. -
The
framework.router.utf8configuration option has been added. If your app's charset is UTF-8 (see kernel'sgetCharset()method), it is recommended to set it totrue: this will generate 404s for non-UTF-8 URLs, which are incompatible with you app anyway, and will allow dumping optimized routers and using Unicode classes in requirements. -
Added support for the SameSite attribute for session cookies. It is highly recommended to set this setting (
framework.session.cookie_samesite) tolaxfor increased security against CSRF attacks. -
The
Controllerclass has been deprecated, useAbstractControllerinstead. -
The Messenger encoder/decoder configuration has been changed for a unified Messenger serializer configuration.
Before:
framework: messenger: encoder: your_encoder_service_id decoder: your_decoder_service_id
After:
framework: messenger: serializer: id: your_messenger_service_id
-
The
ContainerAwareCommandclass has been deprecated, useSymfony\Component\Console\Command\Commandwith dependency injection instead. -
The
Templating\Helper\TranslatorHelper::transChoice()method has been deprecated, use thetrans()one instead with a%count%parameter. -
Deprecated support for legacy translations directories
src/Resources/translations/andsrc/Resources/<BundleName>/translations/, usetranslations/instead. -
Support for the legacy directory structure in
translation:updateanddebug:translationcommands has been deprecated.
- The default value of the
$secureand$samesitearguments of Cookie's constructor will respectively change fromfalsetonulland fromnulltolaxin Symfony 5.0, you should define their values explicitly or useCookie::create()instead.
- The
Kernel::getRootDir()and thekernel.root_dirparameter have been deprecated - The
KernelInterface::getName()and thekernel.nameparameter have been deprecated - Deprecated the first and second constructor argument of
ConfigDataCollector - Deprecated
ConfigDataCollector::getApplicationName() - Deprecated
ConfigDataCollector::getApplicationVersion()
-
The
MiddlewareInterface::handle()andSenderInterface::send()methods must now return anEnvelopeinstance. -
The return value of handlers isn't forwarded anymore by middleware and buses. If you used to return a value, e.g in query bus handlers, you can either:
- get the result from the
HandledStampin the envelope returned by the bus. - use the
HandleTraitto leverage a message bus, expecting a single, synchronous message handling and returning its result. - make your
Querymutable to allow setting & getting a result:// When dispatching: $bus->dispatch($query = new Query()); $result = $query->getResult(); // In your handler: $query->setResult($yourResult);
- get the result from the
-
The
EnvelopeAwareInterfacewas removed and theMiddlewareInterface::handle()method now requires anEnvelopeobject as first argument. When using built-in middleware with the providedMessageBus, you will not have to do anything.
If you use your ownMessageBusInterfaceimplementation, you must wrap the message in anEnvelopebefore passing it to middleware.
If you created your own middleware, you must change the signature to always expect anEnvelope. -
The
MiddlewareInterface::handle()second argument (callable $next) has changed in favor of aStackInterfaceinstance. When using built-in middleware with the providedMessageBus, you will not have to do anything.
If you use your ownMessageBusInterfaceimplementation, you can use theStackMiddlewareimplementation.
If you created your own middleware, you must change the signature to always expect anStackInterfaceinstance and call$stack->next()->handle($envelope, $stack)instead of$nextto call the next middleware:Before:
public function handle($message, callable $next): Envelope { // do something before $message = $next($message); // do something after return $message; }
After:
public function handle(Envelope $envelope, StackInterface $stack): Envelope { // do something before $envelope = $stack->next()->handle($envelope, $stack); // do something after return $envelope; }
-
StampInterfacereplacesEnvelopeItemInterfaceand doesn't extendSerializableanymore. Built-inReceivedMessage,ValidationConfigurationandSerializerConfigurationwere renamed respectivelyReceivedStamp,ValidationStamp,SerializerStampand moved to theStampnamespace. -
AllowNoHandlerMiddlewarehas been removed in favor of a new constructor argument onHandleMessageMiddleware -
The
ConsumeMessagesCommandclass now takes an instance ofPsr\Container\ContainerInterfaceas first constructor argument, i.e a message bus locator. The CLI command now expects a mandatory--busoption value if there is more than one bus in the locator. -
MessageSubscriberInterface::getHandledMessages()return value has changed. The value of an array item needs to be an associative array or the method name.Before:
return [ [FirstMessage::class, 0], [SecondMessage::class, -10], ];
After:
yield FirstMessage::class => ['priority' => 0]; yield SecondMessage::class => ['priority' => -10];
Before:
return [ SecondMessage::class => ['secondMessageMethod', 20], ];
After:
yield SecondMessage::class => [ 'method' => 'secondMessageMethod', 'priority' => 20, ];
-
The
EncoderInterfaceandDecoderInterfaceinterfaces have been replaced by a unifiedSymfony\Component\Messenger\Transport\Serialization\SerializerInterface. Each interface method have been merged untouched into theSerializerinterface, so you can simply merge your two implementations together and implement the new interface. -
The
HandlerLocatorclass was replaced withSymfony\Component\Messenger\Handler\HandlersLocator.Before:
new HandlerLocator([ YourMessage::class => $handlerCallable, ]);
After:
new HandlersLocator([ YourMessage::class => [ $handlerCallable, ] ]);
- The methods
DebugProcessor::getLogs(),DebugProcessor::countErrors(),Logger::getLogs()andLogger::countErrors()will have a new$requestargument in version 5.0, not defining it is deprecated.
-
Deprecated the
Process::setCommandline()and thePhpProcess::setPhpBinary()methods. -
Deprecated passing commands as strings when creating a
Processinstance.Before:
$process = new Process('ls -l');
After:
$process = new Process(array('ls', '-l')); // alternatively, when a shell wrapper is required $process = Process::fromShellCommandline('ls -l');
- Using the
has_role()function in security expressions is deprecated, use theis_granted()function instead. - Not returning an array of 3 elements from
FirewallMapInterface::getListeners()is deprecated, the 3rd element must be an instance ofLogoutListenerornull. - Passing custom class names to the
Symfony\Component\Security\Core\Authentication\AuthenticationTrustResolverto define custom anonymous and remember me token classes is deprecated. To use custom tokens, extend the existingSymfony\Component\Security\Core\Authentication\Token\AnonymousTokenorSymfony\Component\Security\Core\Authentication\Token\RememberMeToken. - Accessing the user object that is not an instance of
UserInterfacefromSecurity::getUser()is deprecated. SimpleAuthenticatorInterface,SimpleFormAuthenticatorInterface,SimplePreAuthenticatorInterface,SimpleAuthenticationProvider,SimpleAuthenticationHandler,SimpleFormAuthenticationListenerandSimplePreAuthenticationListenerhave been deprecated. Use Guard instead.- BC break note: Upgrade to this version will log out all logged in users. See bug #33473.
- Passing a
FirewallConfiginstance as 3rd argument to theFirewallContextconstructor is deprecated, pass aLogoutListenerinstance instead. - Using the
security.authentication.trust_resolver.anonymous_classandsecurity.authentication.trust_resolver.rememberme_classparameters to define the token classes is deprecated. To use custom tokens extend the existing AnonymousToken and RememberMeToken. - The
simple_formandsimple_preauthauthentication listeners have been deprecated, use Guard instead. - The
SimpleFormFactoryandSimplePreAuthenticationFactoryclasses have been deprecated, use Guard instead.
- Relying on the default value (false) of the "as_collection" option is deprecated. You should set it to false explicitly instead as true will be the default value in 5.0.
- The
AbstractNormalizer::handleCircularReference()method will have two new$formatand$contextarguments in version 5.0, not defining them is deprecated.
- The
TranslatorInterfacehas been deprecated in favor ofSymfony\Contracts\Translation\TranslatorInterface - The
Translator::transChoice()method has been deprecated in favor of usingTranslator::trans()with "%count%" as the parameter driving plurals - The
MessageSelector,IntervalandPluralizationRulesclasses have been deprecated, useIdentityTranslatorinstead - The
Translator::getFallbackLocales()andTranslationDataCollector::getFallbackLocales()method have been marked as internal
- The
transchoicetag and filter have been deprecated, use thetransones instead with a%count%parameter. - Deprecated support for legacy templates directories
src/Resources/views/andsrc/Resources/<BundleName>/views/, usetemplates/andtemplates/bundles/<BundleName>/instead.
- The
symfony/translationdependency has been removed - runcomposer require symfony/translationif you need the component - The
checkMXandcheckHostoptions of theEmailconstraint are deprecated - The component is now decoupled from
symfony/translationand usesSymfony\Contracts\Translation\TranslatorInterfaceinstead - The
ValidatorBuilderInterfacehas been deprecated andValidatorBuilder::setTranslator()has been made final - Deprecated validating instances of
\DateTimeInterfaceinDateTimeValidator,DateValidatorandTimeValidator. UseTypeinstead or remove the constraint if the underlying model is type hinted to\DateTimeInterfacealready. - Using the
Bic,Country,Currency,LanguageandLocaleconstraints withoutsymfony/intlis deprecated - Using the
Emailconstraint in strict mode withoutegulias/email-validatoris deprecated - Using the
Expressionconstraint withoutsymfony/expression-languageis deprecated