symfony API

sfYaml Class

You are currently browsing
the website for symfony 1

Visit the Symfony2 website


« Back to API menu

1.3 API OpenSearch

Packages

You are currently browsing the symfony API for the 1.3 version. Switch to:

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) Browse code

    $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) Browse code

    $string The string to echo with new line

    Wraps echo to automatically provide a newline.

  • (string) getSpecVersion () Browse code

    Gets the YAML specification version to use.

    returns The YAML specification version

  • (array) load ($input) Browse code

    $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) Browse code

    $version The YAML specification version

    Sets the YAML specification version to use.