Caution: The documentation you are viewing is
for an older version of Zend Framework.
You can find the documentation of the current version at:
Zend_Config_Yaml - Zend_Config
» YAML is a recursive acronym meaning "YAML Ain't Markup Language", and is intended as a "human friendly data serialization standard for all programming languages." It is often used for application configuration.
Zend_Config_Yaml is a lightweight Zend_Config extension. It includes a parser capable of recognizing most common YAML syntax used for purposes of configuration, and allows specifying other parsers should you want more complex syntax (e.g., ext/syck, spyc, sfYaml, etc.).
The following is a YAML version of a standard application configuration.
To utilize it, you simply instantiate Zend_Config_Yaml, pointing it to the location of this file and indicating the section of the file to load. By default, constant names found in values will be substituted with their appropriate values.
Once instantiated, you use it as you would any other configuration object.
The following options may be passed as keys to the third, $options argument of the constructor.
The default behavior of Zend_Config is to mark the object as immutable once loaded. Passing this flag with a boolean true will enable modifications to the object.
By default, any time a section extends another, Zend_Config will merge the section with the section it extends. Speciying a boolean true value to this option will disable this feature, giving you only the configuration defined explicitly in that section.
By default, Zend_Config_Yaml will replace constant names found in values with the defined constant value. You map pass a boolean true to this option to disable this functionality.
By default, Zend_Config_Yaml uses a built in decoder, Zend_Config_Yaml::decode(), to parse and process YAML files. You may specify an alternate callback to use in place of the built-in one using this option.
Constructor. $yaml should refer to a valid filesystem location containing a YAML configuration file. $section, if specified, indicates a specific section of the configuration file to use. $options is discussed in the options section.
Parses a YAML string into a PHP array.
This static function may be used to globally override the default settings for how constants found in YAML strings are handled. By default, constant names are replaced with the appropriate constant values; passing a boolean true value to this method will override that behavior. (You can override it per-instance via the ignore_constants option as well.)
This static method gives you the current setting for the ignore_constants flag.
Example #1 Using Zend_Config_Yaml with sfYaml
As noted in the options section, Zend_Config_Yaml allows you to specify an alternate YAML parser at instantiation.
» sfYaml is a » Symfony component that implements a complete YAML parser in PHP, and includes a number of additional features including the ability to parse PHP expressions embedded in the YAML. In this example, we use the sfYaml::load() method as our YAML decoder callback. (Note: this assumes that the sfYaml class is either already loaded or available via autoloading.)