GithubHelp home page GithubHelp logo

yaml's Introduction

Yaml

Build StatuscodecovCodacy BadgeMaintainability

An pure PHP implementation base YAML loader/dumper.

  • Given a YAML document, will return an array that you can use however you see fit.

  • Given an array, will return a string which contains a YAML document built from your data.

YAML is an amazingly human friendly and strikingly versatile data serialization language which can be used for log files, config files, custom protocols, the works. For more information, see http://www.yaml.org.

Supporting YAML 1.1 specification.

Installation

composer require symplely/yaml

Usage

Using Yaml is trivial:

The parse() or loader() method parses a YAML string and converts it to a PHP array:

require 'vendor/autoload.php';

use Async\Yaml;

 // Reading YAML Contents
$Data = Yaml::loader('config.yaml');
// Or
$Data = Yaml::parse("foo: bar");
// Or
$Data = yaml_load("foo: bar");
// $Data = ['foo' => 'bar']

or (if you prefer functional syntax)

require 'vendor/autoload.php';

$Data = yaml_load_file('config.yaml');

The dumper() method dumps any PHP array to its YAML representation:

require 'vendor/autoload.php';

use Async\Yaml;

$array = [
    'foo' => 'bar',
    'bar' => ['foo' => 'bar','bar' => 'baz'],
];

$yaml = Yaml::dumper($array);
// Or
$yaml = yaml_dump($array);

// Writing YAML Files
file_put_contents('/path/to/file.yaml', $yaml);

yaml's People

Contributors

4d47 avatar al-the-x avatar castor4bit avatar chernjie avatar elfen avatar entendu avatar eugenealegiojo avatar gulping avatar jackmcdade avatar jasonvarga avatar maadhattah avatar mark-h avatar mustangostang avatar nikerabbit avatar quicksketch avatar ryanuber avatar seebz avatar takamin avatar thetechstech avatar thi3rry avatar tmtysk avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.