1 PHP: 5.2 2 MySQL: 5.1 3 Apache: 2.2.20
YAML uses indentation with one or more spaces to describe nested collections: Listing 49-20
1 "symfony 1.0": 2 PHP: 5.0 3 Propel: 1.2 4 "symfony 1.2": 5 PHP: 5.2 6 Propel: 1.3
The following YAML is equivalent to the following PHP code: Listing 49-21
1 array( 2 'symfony 1.0' 3 'PHP' => 4 'Propel' => 5 ), 6 'symfony 1.2' 7 'PHP' => 8 'Propel' => 9 ), 10 );
=> array( 5.0, 1.2, => array( 5.2, 1.3,
There is one important thing you need to remember when using indentation in a YAML file: Indentation must be done with one or more spaces, but never with tabulations. You can nest sequences and mappings as you like: Listing 49-22
1 'Chapter 1': 2 - Introduction 3 - Event Types 4 'Chapter 2': 5 - Introduction 6 - Helpers
YAML can also use flow styles for collections, using explicit indicators rather than indentation to denote scope. A sequence can be written as a comma separated list within square brackets ([]): Listing 49-23
1 [PHP, Perl, Python]
A mapping can be written as a comma separated list of key/values within curly braces ({}): Listing 49-24
1 { PHP: 5.2, MySQL: 5.1, Apache: 2.2.20 }
You can mix and match styles to achieve a better readability: Listing 49-25
1 'Chapter 1': [Introduction, Event Types] 2 'Chapter 2': [Introduction, Helpers]
Listing 49-26
PDF brought to you by generated on March 17, 2013
Chapter 49: The YAML Format | 205