Contributed by
Christian Flothmann
in #16201,
#16285
and
#16433.
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 \
backslash
doubling it:
1 2 3 4 5 6 | app.user_manager:
# remove double quotes...
class: AppBundle\Manager\UserManager
# ...or escape backslashes
class: "AppBundle\\Manager\\UserManager"
# ...
|
@
at the beginning of unquoted strings¶This deprecation has a big impact because lots of services use the @service_id
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']
|
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.
What a Symfony developer should know about the framework: News, Jobs, Tweets, Events, Videos,...