symfony API

sfYaml Class

You are currently browsing
the website for symfony 1

Visit the Symfony2 website


« Back to API menu

Packages

You are currently browsing the symfony API for the 1.4 version. Switch to:
This version of symfony is not maintained anymore.
If some of your projects still use this version, consider upgrading as soon as possible.

sfYaml offers convenience methods to load and dump YAML.

Method Summary

  • string dump($array, $inline)
    Dumps a PHP array to a YAML string.
  • echoln($string)
    Wraps echo to automatically provide a newline.
  • string getSpecVersion()
    Gets the YAML specification version to use.
  • array load($input)
    Loads YAML into a PHP array.
  • setSpecVersion($version)
    Sets the YAML specification version to use.

Method Details

  • (string) dump ($array, $inline)

    $array PHP array
    $inline The level where you switch to inline YAML

    Dumps a PHP array to a YAML string.


    The dump method, when supplied with an array, will do its best
    to convert the array into friendly YAML.

    returns A YAML string representing the original PHP array

  • echoln ($string)

    $string The string to echo with new line

    Wraps echo to automatically provide a newline.

  • (string) getSpecVersion ()

    Gets the YAML specification version to use.

    returns The YAML specification version

  • (array) load ($input)

    $input Path of YAML file or string containing YAML

    Loads YAML into a PHP array.


    The load method, when supplied with a YAML stream (string or file),
    will do its best to convert YAML in a file into a PHP array.

    Usage:

    $array = sfYaml::load('config.yml');
    print_r($array);

    returns The YAML converted to a PHP array

    throws InvalidArgumentException If the YAML is not valid

  • setSpecVersion ($version)

    $version The YAML specification version

    Sets the YAML specification version to use.