New in Symfony 2.8: YAML deprecations
The upcoming Symfony 3.1 version will introduce lots of new and useful features for the Yaml component. But before enjoying those features, in Symfony 2.8 we needed to deprecate some features to make Yaml files comply with the Yaml specification. Make sure to fix all these changes before upgrading your applications to Symfony 3.
\ in double-quoted strings¶
This deprecation is common when defining the classes of the services:
1 2 3
app.user_manager: class: "AppBundle\Manager\UserManager" # ...
The alternative is either remove the double quotes or escape the
1 2 3 4 5 6
app.user_manager: # remove double quotes... class: AppBundle\Manager\UserManager # ...or escape backslashes class: "AppBundle\\Manager\\UserManager" # ...
Deprecated usage of
@ at the beginning of unquoted strings¶
This deprecation has a big impact because lots of services use the
notation to define their dependencies:
1 2 3
app.user_manager: # ... arguments: [@router, @logger, @doctrine.orm.entity_manager]
According to Yaml specification, unquoted strings cannot start with
@, so you
must wrap these arguments with single or double quotes:
1 2 3
app.user_manager: # ... arguments: ['@router', '@logger', '@doctrine.orm.entity_manager']
Deprecated usage of reserved characters at the beginning of unquoted strings¶
These deprecations should have a low impact for Symfony developers because it's uncommon to use these characters as the beginning of unquoted strings:
1 2 3
app.user_manager: # ... arguments: [`string`, |string, >string]
The solution is to wrap these strings with single or double quotes:
1 2 3
app.user_manager: # ... arguments: ['`string`', '|string', '>string']
Deprecations are always a pain for developers and we try to avoid them as much as possible. But allowing to create Yaml files which don't respect the official specification is unquestionably wrong. The recent Symfony 3.0 release was the perfect moment to fix these problems.
Comments are closed.
To ensure that comments stay relevant, they are closed for old posts.