* 4.4: Extract Abstract Doctrine Middleware [Translation] refactor ArrayLoader::flatten [TwigBundle] mark TemplateIterator as internal Improved error message on create a form builder with invalid options [Security] add PasswordEncoderInterface::needsRehash() [HttpClient] add $response->cancel() Add clear Entity Manager middleware (closes #29662) [FrameworkBundle] Add missing BC layer for deprecated ControllerNameParser injections [Validator] Improve TypeValidator to handle array of types Add exception as HTML comment to beginning and end of `exception_full.html.twig` [Validator] Add compared value path to violation parameters
21 KiB
UPGRADE FROM 4.x to 5.0
BrowserKit
- Removed
Client
, useAbstractBrowser
instead - Removed the possibility to extend
Response
by making it final. - Removed
Response::buildHeader()
- Removed
Response::getStatus()
, useResponse::getStatusCode()
instead - The
Client::submit()
method has a new$serverParameters
argument.
Cache
- Removed
CacheItem::getPreviousTags()
, useCacheItem::getMetadata()
instead. - Removed all PSR-16 adapters, use
Psr16Cache
orSymfony\Contracts\Cache\CacheInterface
implementations instead. - Removed
SimpleCacheAdapter
, usePsr16Adapter
instead.
Config
- Dropped support for constructing a
TreeBuilder
without passing root node information. - Added the
getChildNodeDefinitions()
method toParentNodeDefinitionInterface
. - The
Processor
class has been made final - Removed
FileLoaderLoadException
, useLoaderLoadException
instead. - Using environment variables with
cannotBeEmpty()
if the value is validated withvalidate()
will throw an exception. - Removed the
root()
method inTreeBuilder
, pass the root node information to the constructor instead
Console
-
Removed the
setCrossingChar()
method in favor of thesetDefaultCrossingChar()
method inTableStyle
. -
Removed the
setHorizontalBorderChar()
method in favor of thesetDefaultCrossingChars()
method inTableStyle
. -
Removed the
getHorizontalBorderChar()
method in favor of thegetBorderChars()
method inTableStyle
. -
Removed the
setVerticalBorderChar()
method in favor of thesetVerticalBorderChars()
method inTableStyle
. -
Removed the
getVerticalBorderChar()
method in favor of thegetBorderChars()
method inTableStyle
. -
The
ProcessHelper::run()
method takes the command as an array of arguments.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'));
DependencyInjection
-
Removed the
TypedReference::canBeAutoregistered()
andTypedReference::getRequiringClass()
methods. -
Removed support for auto-discovered extension configuration class which does not implement
ConfigurationInterface
. -
Removed support for non-string default env() parameters
Before:
parameters: env(NAME): 1.5
After:
parameters: env(NAME): '1.5'
-
Removed support for short factories and short configurators in Yaml
Before:
services: my_service: factory: factory_service:method
After:
services: my_service: factory: ['@factory_service', method]
DoctrineBridge
- Deprecated injecting
ClassMetadataFactory
inDoctrineExtractor
, an instance ofEntityManagerInterface
should be injected instead - Passing an
IdReader
to theDoctrineChoiceLoader
when the query cannot be optimized with single id field will throw an exception, passnull
instead - Not passing an
IdReader
to theDoctrineChoiceLoader
when the query can be optimized with single id field will throw an exception
DomCrawler
- The
Crawler::children()
method has a new$selector
argument.
Dotenv
- First parameter
$usePutenv
ofDotenv::__construct()
now default tofalse
.
EventDispatcher
- The
TraceableEventDispatcherInterface
has been removed. - The signature of the
EventDispatcherInterface::dispatch()
method has been updated todispatch($event, string $eventName = null)
- The
Event
class has been removed, useSymfony\Contracts\EventDispatcher\Event
instead
Filesystem
- The
Filesystem::dumpFile()
method no longer supports arrays in the$content
argument. - The
Filesystem::appendToFile()
method no longer supports arrays in the$content
argument.
Finder
- The
Finder::sortByName()
method has a new$useNaturalSort
argument.
Form
-
Removed support for using the
format
option ofDateType
andDateTimeType
when thehtml5
option is enabled. -
Using names for buttons that do not start with a letter, a digit, or an underscore leads to an exception.
-
Using names for buttons that do not contain only letters, digits, underscores, hyphens, and colons leads to an exception.
-
Using the
date_format
,date_widget
, andtime_widget
options of theDateTimeType
when thewidget
option is set tosingle_text
is not supported anymore. -
The
getExtendedType()
method was removed from theFormTypeExtensionInterface
. It is replaced by the the staticgetExtendedTypes()
method which must 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
scale
option was removed from theIntegerType
. -
The
$scale
argument of theIntegerToLocalizedStringTransformer
was removed. -
Calling
FormRenderer::searchAndRenderBlock
for fields which were already rendered throws an exception instead of returning empty strings:Before:
{% for field in fieldsWithPotentialDuplicates %} {{ form_widget(field) }} {% endfor %}
After:
{% for field in fieldsWithPotentialDuplicates if not field.rendered %} {{ form_widget(field) }} {% endfor %}
-
The
regions
option was removed from theTimezoneType
.
FrameworkBundle
-
The project dir argument of the constructor of
AssetsInstallCommand
is required. -
Removed support for
bundle:controller:action
syntax to reference controllers. UseserviceOrFqcn::method
instead whereserviceOrFqcn
is either the service ID when using controllers as services or the FQCN of the controller.Before:
bundle_controller: path: / defaults: _controller: FrameworkBundle:Redirect:redirect
After:
bundle_controller: path: / defaults: _controller: Symfony\Bundle\FrameworkBundle\Controller\RedirectController::redirectAction
-
Removed
Symfony\Bundle\FrameworkBundle\Controller\ControllerNameParser
. -
Warming up a router in
RouterCacheWarmer
that does not implement theWarmableInterface
is not supported anymore. -
The
RequestDataCollector
class has been removed. Use theSymfony\Component\HttpKernel\DataCollector\RequestDataCollector
class instead. -
Removed
Symfony\Bundle\FrameworkBundle\Controller\Controller
. UseSymfony\Bundle\FrameworkBundle\Controller\AbstractController
instead. -
Added support for the SameSite attribute for session cookies. It is highly recommended to set this setting (
framework.session.cookie_samesite
) tolax
for increased security against CSRF attacks. -
The
ContainerAwareCommand
class has been removed, useSymfony\Component\Console\Command\Command
with dependency injection instead. -
The
Templating\Helper\TranslatorHelper::transChoice()
method has been removed, use thetrans()
one instead with a%count%
parameter. -
Removed support for legacy translations directories
src/Resources/translations/
andsrc/Resources/<BundleName>/translations/
, usetranslations/
instead. -
Support for the legacy directory structure in
translation:update
anddebug:translation
commands has been removed. -
Removed the "Psr\SimpleCache\CacheInterface" / "cache.app.simple" service, use "Symfony\Contracts\Cache\CacheInterface" / "cache.app" instead.
-
Removed support for
templating
engine inTemplateController
, use Twig instead
HttpClient
- Added method
cancel()
toResponseInterface
- The
$parser
argument ofControllerResolver::__construct()
andDelegatingLoader::__construct()
has been removed. - The
ControllerResolver
andDelegatingLoader
classes have been madefinal
. - The
controller_name_converter
andresolve_controller_name_subscriber
services have been removed.
HttpFoundation
- The
$size
argument of theUploadedFile
constructor has been removed. - The
getClientSize()
method of theUploadedFile
class has been removed. - The
getSession()
method of theRequest
class throws an exception when session is null. - The default value of the "$secure" and "$samesite" arguments of Cookie's constructor changed respectively from "false" to "null" and from "null" to "lax".
- The
MimeTypeGuesserInterface
andExtensionGuesserInterface
interfaces have been removed, useSymfony\Component\Mime\MimeTypesInterface
instead. - The
MimeType
andMimeTypeExtensionGuesser
classes have been removed, useSymfony\Component\Mime\MimeTypes
instead. - The
FileBinaryMimeTypeGuesser
class has been removed, useSymfony\Component\Mime\FileBinaryMimeTypeGuesser
instead. - The
FileinfoMimeTypeGuesser
class has been removed, useSymfony\Component\Mime\FileinfoMimeTypeGuesser
instead.
HttpKernel
- Removed
Client
, useHttpKernelBrowser
instead - The
Kernel::getRootDir()
and thekernel.root_dir
parameter have been removed - The
KernelInterface::getName()
and thekernel.name
parameter have been removed - Removed the first and second constructor argument of
ConfigDataCollector
- Removed
ConfigDataCollector::getApplicationName()
- Removed
ConfigDataCollector::getApplicationVersion()
- Removed
FilterControllerArgumentsEvent
, useControllerArgumentsEvent
instead - Removed
FilterControllerEvent
, useControllerEvent
instead - Removed
FilterResponseEvent
, useResponseEvent
instead - Removed
GetResponseEvent
, useRequestEvent
instead - Removed
GetResponseForControllerResultEvent
, useViewEvent
instead - Removed
GetResponseForExceptionEvent
, useExceptionEvent
instead - Removed
PostResponseEvent
, useTerminateEvent
instead - Removed
TranslatorListener
in favor ofLocaleAwareListener
- The
DebugHandlersListener
class has been madefinal
Intl
- Removed
ResourceBundle
namespace - Removed
Intl::getLanguageBundle()
, useLanguages
orScripts
instead - Removed
Intl::getCurrencyBundle()
, useCurrencies
instead - Removed
Intl::getLocaleBundle()
, useLocales
instead - Removed
Intl::getRegionBundle()
, useCountries
instead
Messenger
- The
LoggingMiddleware
class has been removed, pass a logger toSendMessageMiddleware
instead. - Passing a
ContainerInterface
instance as first argument of theConsumeMessagesCommand
constructor now throws as\TypeError
, pass aRoutableMessageBus
instance instead.
Monolog
- The methods
DebugProcessor::getLogs()
,DebugProcessor::countErrors()
,Logger::getLogs()
andLogger::countErrors()
have a new$request
argument.
MonologBridge
- The
RouteProcessor
class is final.
Process
-
Removed the
Process::setCommandline()
and thePhpProcess::setPhpBinary()
methods. -
Commands must be defined as arrays when creating a
Process
instance.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');
Routing
- The
generator_base_class
,generator_cache_class
,matcher_base_class
, andmatcher_cache_class
router options have been removed. Route
andCompiledRoute
don't implementSerializable
anymore; if you serialize them, please ensure your unserialization logic can recover from a failure related to an updated serialization format
Security
-
Implementations of
PasswordEncoderInterface
andUserPasswordEncoderInterface
must have a newneedsRehash()
method -
The
Role
andSwitchUserRole
classes have been removed. -
The
getReachableRoles()
method of theRoleHierarchy
class has been removed. It has been replaced by the newgetReachableRoleNames()
method. -
The
getRoles()
method has been removed from theTokenInterface
. It has been replaced by the newgetRoleNames()
method. -
The
ContextListener::setLogoutOnUserChange()
method has been removed. -
The
Symfony\Component\Security\Core\User\AdvancedUserInterface
has been removed. -
The
ExpressionVoter::addExpressionLanguageProvider()
method has been removed. -
The
FirewallMapInterface::getListeners()
method must return an array of 3 elements, the 3rd one must be either aLogoutListener
instance ornull
. -
The
AuthenticationTrustResolver
constructor arguments have been removed. -
A user object that is not an instance of
UserInterface
cannot be accessed fromSecurity::getUser()
anymore and returnsnull
instead. -
SimpleAuthenticatorInterface
,SimpleFormAuthenticatorInterface
,SimplePreAuthenticatorInterface
,SimpleAuthenticationProvider
,SimpleAuthenticationHandler
,SimpleFormAuthenticationListener
andSimplePreAuthenticationListener
have been removed. Use Guard instead. -
The
ListenerInterface
has been removed, turn your listeners into callables instead. -
The
Firewall::handleRequest()
method has been removed, useFirewall::callListeners()
instead. -
\Serializable
interface has been removed fromAbstractToken
andAuthenticationException
, thusserialize()
andunserialize()
aren't available. Use__serialize()
and__unserialize()
instead.Before:
public function serialize() { return [$this->myLocalVar, parent::serialize()]; } public function unserialize($serialized) { [$this->myLocalVar, $parentSerialized] = unserialize($serialized); parent::unserialize($parentSerialized); }
After:
public function __serialize(): array { return [$this->myLocalVar, parent::__serialize()]; } public function __unserialize(array $data): void { [$this->myLocalVar, $parentData] = $data; parent::__unserialize($parentData); }
-
The
Argon2iPasswordEncoder
class has been removed, useSodiumPasswordEncoder
instead. -
The
BCryptPasswordEncoder
class has been removed, useNativePasswordEncoder
instead. -
Classes implementing the
TokenInterface
must implement the two new methods__serialize
and__unserialize
SecurityBundle
- The
logout_on_user_change
firewall option has been removed. - The
switch_user.stateless
firewall option has been removed. - The
SecurityUserValueResolver
class has been removed. - Passing a
FirewallConfig
instance as 3rd argument to theFirewallContext
constructor now throws a\TypeError
, pass aLogoutListener
instance instead. - The
security.authentication.trust_resolver.anonymous_class
parameter has been removed. - The
security.authentication.trust_resolver.rememberme_class
parameter has been removed. - The
simple_form
andsimple_preauth
authentication listeners have been removed, use Guard instead. - The
SimpleFormFactory
andSimplePreAuthenticationFactory
classes have been removed, use Guard instead. - The names of the cookies configured in the
logout.delete_cookies
option are no longer normalized. If any of your cookie names has dashes they won't be changed to underscores. Before:my-cookie
deleted themy_cookie
cookie (with an underscore). After:my-cookie
deletes themy-cookie
cookie (with a dash). - Configuring encoders using
argon2i
orbcrypt
as algorithm is not supported anymore, useauto
instead.
Serializer
-
The default value of the
CsvEncoder
"as_collection" option was changed totrue
. -
Individual encoders & normalizers options as constructor arguments were removed. Use the default context instead.
-
The following method and properties:
AbstractNormalizer::$circularReferenceLimit
AbstractNormalizer::$circularReferenceHandler
AbstractNormalizer::$callbacks
AbstractNormalizer::$ignoredAttributes
AbstractNormalizer::$camelizedAttributes
AbstractNormalizer::setCircularReferenceLimit()
AbstractNormalizer::setCircularReferenceHandler()
AbstractNormalizer::setCallbacks()
AbstractNormalizer::setIgnoredAttributes()
AbstractObjectNormalizer::$maxDepthHandler
AbstractObjectNormalizer::setMaxDepthHandler()
XmlEncoder::setRootNodeName()
XmlEncoder::getRootNodeName()
were removed, use the default context instead.
-
The
AbstractNormalizer::handleCircularReference()
method has two new$format
and$context
arguments.
Translation
- The
FileDumper::setBackup()
method has been removed. - The
TranslationWriter::disableBackup()
method has been removed. - The
TranslatorInterface
has been removed in favor ofSymfony\Contracts\Translation\TranslatorInterface
- The
MessageSelector
,Interval
andPluralizationRules
classes have been removed, useIdentityTranslator
instead - The
Translator::getFallbackLocales()
andTranslationDataCollector::getFallbackLocales()
method are now internal - The
Translator::transChoice()
method has been removed in favor of usingTranslator::trans()
with "%count%" as the parameter driving plurals
TwigBundle
- The default value (
false
) of thetwig.strict_variables
configuration option has been changed to%kernel.debug%
. - The
transchoice
tag and filter have been removed, use thetrans
ones instead with a%count%
parameter. - Removed support for legacy templates directories
src/Resources/views/
andsrc/Resources/<BundleName>/views/
, usetemplates/
andtemplates/bundles/<BundleName>/
instead.
TwigBridge
- Removed argument
$rootDir
from theDebugCommand::__construct()
method and the 5th argument must be an instance ofFileLinkFormatter
- removed the
$requestStack
and$requestContext
arguments of theHttpFoundationExtension
, pass aSymfony\Component\HttpFoundation\UrlHelper
instance as the only argument instead
Validator
- The
checkMX
andcheckHost
options of theEmail
constraint were removed - The
Email::__construct()
'strict' property has been removed. Use 'mode'=>"strict" instead. - Calling
EmailValidator::__construct()
method with a boolean parameter has been removed, useEmailValidator("strict")
instead. - Removed the
checkDNS
anddnsMessage
options from theUrl
constraint. - The component is now decoupled from
symfony/translation
and usesSymfony\Contracts\Translation\TranslatorInterface
instead - The
ValidatorBuilderInterface
has been removed andValidatorBuilder
is now final - Removed support for validating instances of
\DateTimeInterface
inDateTimeValidator
,DateValidator
andTimeValidator
. UseType
instead or remove the constraint if the underlying model is type hinted to\DateTimeInterface
already. - The
symfony/intl
component is now required for using theBic
,Country
,Currency
,Language
andLocale
constraints - The
egulias/email-validator
component is now required for using theEmail
constraint in strict mode - The
symfony/expression-language
component is now required for using theExpression
constraint
Workflow
-
The
DefinitionBuilder::reset()
method has been removed, use theclear()
one instead. -
add
method has been removed useaddWorkflow
method inWorkflow\Registry
instead. -
SupportStrategyInterface
has been removed, useWorkflowSupportStrategyInterface
instead. -
ClassInstanceSupportStrategy
has been removed, useInstanceOfSupportStrategy
instead. -
MarkingStoreInterface::setMarking()
has a third argument:array $context = []
. -
Removed support of
initial_place
. Useinitial_places
instead. -
MultipleStateMarkingStore
has been removed. UseMethodMarkingStore
instead.Before:
framework: workflows: type: workflow article: marking_store: type: multiple arguments: states
After:
framework: workflows: type: workflow article: marking_store: property: states
-
SingleStateMarkingStore
has been removed. UseMethodMarkingStore
instead.Before:
framework: workflows: article: marking_store: arguments: state
After:
framework: workflows: article: marking_store: property: state
-
Support for using a workflow with a single state marking is dropped. Use a state machine instead.
Before:
framework: workflows: article: type: workflow marking_store: type: single_state
After:
framework: workflows: article: type: state_machine
Yaml
- The parser is now stricter and will throw a
ParseException
when a mapping is found inside a multi-line string.