Symfony News

New in Symfony 3.2: YAML deprecations

Symfony 3.2 will introduce some minor YAML deprecations in order to make the Yaml component fully compliant with the YAML specification.

Deprecated missing spaces after map keys

Contributed by
Christian Flothmann
in #19504.

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 ParseException.

 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

Deprecated defining duplicated keys

Contributed by
Alex Pott
in #19529.

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 keys.

Moved the yaml:lint command to the Yaml component

Contributed by
Robin Chalas
in #19139.

Not strictly a deprecation, but in Symfony 3.2 we decided to move the yaml:lint 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

Be trained by Symfony experts - 2016-09-12 Paris - 2016-09-12 Paris - 2016-09-12 Paris


About us

What a Symfony developer should know about the framework: News, Jobs, Tweets, Events, Videos,...

Resources

Find us on Twitter

Find us on Facebook