- Added argument
$prefixtoAdapterInterface::clear()
- Deprecated finding hidden commands using an abbreviation, use the full name instead
- Deprecated the
Debugclass, use the one from theErrorRenderercomponent instead - Deprecated the
FlattenExceptionclass, use the one from theErrorRenderercomponent instead - Deprecated the component in favor of the
ErrorHandlercomponent
-
Made singly-implemented interfaces detection be scoped by file
-
Deprecated 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]
-
Deprecated
taggedin favor oftagged_iteratorBefore:
services: App\HandlerCollection: arguments: [!tagged my_tag]
After:
services: App\HandlerCollection: arguments: [!tagged_iterator my_tag]
-
Passing an instance of
Symfony\Component\DependencyInjection\Parameteras class name toSymfony\Component\DependencyInjection\Definitionis deprecated.Before:
new Definition(new Parameter('my_class'));
After:
new Definition('%my_class%');
- Deprecated injecting
ClassMetadataFactoryinDoctrineExtractor, an instance ofEntityManagerInterfaceshould be injected instead. - Deprecated passing an
IdReaderto theDoctrineChoiceLoaderwhen the query cannot be optimized with single id field. - Deprecated not passing an
IdReaderto theDoctrineChoiceLoaderwhen the query can be optimized with single id field. - Deprecated
RegistryInterface, useDoctrine\Common\Persistence\ManagerRegistry. - Added a new
getMetadataDriverClassmethod to replace class parameters inAbstractDoctrineExtension. This method will be abstract in Symfony 5 and must be declared in extending classes.
- Support for passing a
nullvalue toFilesystem::isAbsolutePath()is deprecated.
- Using different values for the "model_timezone" and "view_timezone" options of the
TimeTypewithout configuring a reference date is deprecated. - Using
intorfloatas data for theNumberTypewhen theinputoption is set tostringis deprecated. - Overriding the methods
FormIntegrationTestCase::setUp(),TypeTestCase::setUp()andTypeTestCase::tearDown()without thevoidreturn-type is deprecated.
- Deprecated booting the kernel before running
WebTestCase::createClient(). - Deprecated support for
templatingengine inTemplateController, use Twig instead - The
$parserargument ofControllerResolver::__construct()andDelegatingLoader::__construct()has been deprecated. - The
ControllerResolverandDelegatingLoaderclasses have been marked asfinal. - The
controller_name_converterandresolve_controller_name_subscriberservices have been deprecated. - Deprecated
routing.loader.service, userouting.loader.containerinstead. - Not tagging service route loaders with
routing.route_loaderhas been deprecated. - Overriding the methods
KernelTestCase::tearDown()andWebTestCase::tearDown()without thevoidreturn-type is deprecated.
- Added method
cancel()toResponseInterface
ApacheRequestis deprecated, useRequestclass instead.- Passing a third argument to
HeaderBag::get()is deprecated since Symfony 4.4, use methodall()instead PdoSessionHandlernow precalculates the expiry timestamp in the lifetime column, make sure to runCREATE INDEX EXPIRY ON sessions (sess_lifetime)to update your database to speed up garbage collection of expired sessions.
-
The
DebugHandlersListenerclass has been marked asfinal -
Added new Bundle directory convention consistent with standard skeletons:
└── MyBundle/ ├── config/ ├── public/ ├── src/ │ └── MyBundle.php ├── templates/ └── translations/To make this work properly, it is necessary to change the root path of the bundle:
class MyBundle extends Bundle { public function getPath(): string { return \dirname(__DIR__); } }
As many bundles must be compatible with a range of Symfony versions, the current directory convention is not deprecated yet, but it will be in the future.
-
Deprecated the second and third argument of
KernelInterface::locateResource -
Deprecated the second and third argument of
FileLocator::__construct -
Deprecated loading resources from
%kernel.root_dir%/Resourcesand%kernel.root_dir%as fallback directories. Resources like service definitions are usually loaded relative to the current directory or with a glob pattern. The fallback directories have never been advocated so you likely do not use those in any app based on the SF Standard or Flex edition. -
Getting the container from a non-booted kernel is deprecated
- Deprecated
Symfony\Component\Lock\StoreInterfacein favor ofSymfony\Component\Lock\BlockingStoreInterfaceandSymfony\Component\Lock\PersistingStoreInterface. Factoryis deprecated, useLockFactoryinstead
- Deprecated passing a
ContainerInterfaceinstance as first argument of theConsumeMessagesCommandconstructor, pass aRoutableMessageBusinstance instead.
- Removed
NamedAddress, useAddressinstead (which supports a name now)
- The
RouteProcessorhas been marked final.
- Deprecated the
Process::inheritEnvironmentVariables()method: env variables are always inherited.
- Deprecated passing
nullas 2nd argument ofPropertyAccessor::createCache()method ($defaultLifetime), pass0instead.
- Deprecated
ServiceRouterLoaderin favor ofContainerLoader. - Deprecated
ObjectRouteLoaderin favor ofObjectLoader.
-
The
LdapUserProviderclass has been deprecated, useSymfony\Component\Ldap\Security\LdapUserProviderinstead. -
Implementations of
PasswordEncoderInterfaceandUserPasswordEncoderInterfaceshould add a newneedsRehash()method -
Deprecated returning a non-boolean value when implementing
Guard\AuthenticatorInterface::checkCredentials(). Please explicitly returnfalseto indicate invalid credentials. -
Deprecated passing more than one attribute to
AccessDecisionManager::decide()andAuthorizationChecker::isGranted()(and indirectly theis_granted()Twig and ExpressionLanguage function)Before
if ($this->authorizationChecker->isGranted(['ROLE_USER', 'ROLE_ADMIN'])) { // ... }
After
if ($this->authorizationChecker->isGranted(new Expression("has_role('ROLE_USER') or has_role('ROLE_ADMIN')"))) {} // or: if ($this->authorizationChecker->isGranted('ROLE_USER') || $this->authorizationChecker->isGranted('ROLE_ADMIN') ) {}
- Deprecated passing
nullas 1st ($id) argument ofSection::get()method, pass a valid child section identifier instead.
- Deprecated support for using
nullas the locale inTranslator. - Deprecated accepting STDIN implicitly when using the
lint:xliffcommand, uselint:xliff -(append a dash) instead to make it explicit.
- Deprecated to pass
$rootDirand$fileLinkFormatteras 5th and 6th argument respectively to theDebugCommand::__construct()method, swap the variables position. - Deprecated accepting STDIN implicitly when using the
lint:twigcommand, uselint:twig -(append a dash) instead to make it explicit.
-
Deprecated
twig.exception_controllerconfiguration option, set it to "null" and useframework.error_controllerinstead:Before:
twig: exception_controller: 'App\Controller\MyExceptionController'
After:
twig: exception_controller: null framework: error_controller: 'App\Controller\MyExceptionController'
The new default exception controller will also change the error response content according to https://tools.ietf.org/html/rfc7807 for
json,xml,atomandtxtformats:Before:
{ "error": { "code": 404, "message": "Sorry, the page you are looking for could not be found" } }After:
{ "title": "Not Found", "status": 404, "detail": "Sorry, the page you are looking for could not be found" } -
Deprecated the
ExceptionControllerandPreviewErrorControllercontrollers, useErrorControllerfrom the HttpKernel component instead -
Deprecated all built-in error templates, use the error renderer mechanism of the
ErrorRenderercomponent -
Deprecated loading custom error templates in non-html formats. Custom HTML error pages based on Twig keep working as before:
Before (
templates/bundles/TwigBundle/Exception/error.jsonld.twig):{ "@id": "https://example.com", "@type": "error", "@context": { "title": "{{ status_text }}", "code": {{ status_code }}, "message": "{{ exception.message }}" } }After (
App\ErrorRenderer\JsonLdErrorRenderer):class JsonLdErrorRenderer implements ErrorRendererInterface { public static function getFormat(): string { return 'jsonld'; } public function render(FlattenException $exception): string { return json_encode([ '@id' => 'https://example.com', '@type' => 'error', '@context' => [ 'title' => $exception->getTitle(), 'code' => $exception->getStatusCode(), 'message' => $exception->getMessage(), ], ]); } }
Configure your rendering service tagging it with error_renderer.renderer.
- Deprecated passing an
ExpressionLanguageinstance as the second argument ofExpressionValidator::__construct(). - Deprecated using anything else than a
stringas the code of aConstraintViolation, astringtype-hint will be added to the constructor of theConstraintViolationclass and to theConstraintViolationBuilder::setCode()method in 5.0. - Deprecated passing an
ExpressionLanguageinstance as the second argument ofExpressionValidator::__construct(). Pass it as the first argument instead. - The
Lengthconstraint expects theallowEmptyStringoption to be defined when theminoption is used. Set it totrueto keep the current behavior andfalseto reject empty strings. In 5.0, it'll become optional and will default tofalse. - Overriding the methods
ConstraintValidatorTestCase::setUp()andConstraintValidatorTestCase::tearDown()without thevoidreturn-type is deprecated. - deprecated
Symfony\Component\Validator\Mapping\Cache\CacheInterfaceand all implementations in favor of PSR-6. - deprecated
ValidatorBuilder::setMetadataCache, useValidatorBuilder::setMappingCacheinstead.
- Deprecated the
ExceptionControllerclass in favor ofExceptionErrorController - Deprecated the
TemplateManager::templateExists()method
- The bundle is deprecated and will be removed in 5.0.
- Deprecated accepting STDIN implicitly when using the
lint:yamlcommand, uselint:yaml -(append a dash) instead to make it explicit.