New in Symfony 3.2: YAML deprecations
Warning: This post is about an unsupported Symfony version. Some of this information may be out of date. Read the most recent Symfony Docs.
Symfony 3.2 will introduce some minor YAML deprecations in order to make the Yaml component fully compliant with the YAML specification.
When defining a map, YAML requires to add at least one white space after the
colon that separates the key and the value. In previous Symfony versions we
didn't require to include that white space. In Symfony 3.2 we've deprecated this
behavior and Symfony 4.0 will throw a
1 2 3 4 5 6 7 8 9 10 11
# It works in Symfony 3.1, it's deprecated in 3.2, it fails in 4.0 parameters: foo:bar published:true default_page:1 # It works in every past, present and future Symfony version parameters: foo: bar published: true default_page: 1
In previous Symfony versions, when a single YAML file contained duplicated keys the first key was used and the rest were silently ignored:
1 2 3 4 5 6
# the second key is ignored and this document is parsed # as: 'parameters' => array('key' => 'aaa') parameters: key: 'aaa' # ... key: 'bbb'
In Symfony 3.2 this behavior is deprecated and Symfony 4.0 will throw a
ParseException, so it's time to check if your YAML files contain duplicated
Not strictly a deprecation, but in Symfony 3.2 we decided to move the
command from the FrameworkBundle to the Yaml component. This will allow you to
lint your YAML files without having to require the entire FrameworkBundle.
The only difference is that when using
yaml:lint via the component you can
check files and directories, whereas using it in the full-stack framework also
lets you check entire bundles:
1 2 3 4 5 6
# it works in the component and the framework $ ./bin/console yaml:lint parameters.yml $ ./bin/console yaml:lint app/config/ # it only works in the framework $ ./bin/console yaml:lint @AppBundle
Comments are closed.
To ensure that comments stay relevant, they are closed for old posts.