PHPackages                             originphp/yaml - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. originphp/yaml

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

originphp/yaml
==============

OriginPHP Yaml

2.1.3(5y ago)1926[1 issues](https://github.com/originphp/yaml/issues)2MITPHPPHP &gt;=7.3.0CI failing

Since Oct 12Pushed 5y ago1 watchersCompare

[ Source](https://github.com/originphp/yaml)[ Packagist](https://packagist.org/packages/originphp/yaml)[ Docs](https://www.originphp.com)[ RSS](/packages/originphp-yaml/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependencies (2)Versions (12)Used By (2)

Yaml
====

[](#yaml)

[![license](https://camo.githubusercontent.com/6fdb99389fe9d9e8a5c197002a191ace7c8b12a2020c0fa5756cf17aa08a4966/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874477265656e2e737667)](https://camo.githubusercontent.com/6fdb99389fe9d9e8a5c197002a191ace7c8b12a2020c0fa5756cf17aa08a4966/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874477265656e2e737667)[![build](https://github.com/originphp/yaml/workflows/CI/badge.svg)](https://github.com/originphp/yaml/actions)[![coverage](https://camo.githubusercontent.com/14e09c5d92d3ec9070b19afc000a4ea2dbd8fcdf80f262a823ba3a8454c0b39a/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f6f726967696e7068702f79616d6c2f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/originphp/yaml?branch=master)

The YAML utility is for reading (parsing) and writing YAML files.

> The YAML utility does not cover the complete specification, it is designed to read and write configuration files, and data from the database so that it can be read and edited in user friendly way.

Installation
------------

[](#installation)

To install this package

```
$ composer require originphp/yaml

```

Create a YAML string
--------------------

[](#create-a-yaml-string)

```
use Origin\Yaml\Yaml;
$employees = [
    ['name'=>'Jim','skills'=>['php','mysql','puppeteer']],
    ['name'=>'Amy','skills'=>['ruby','ruby on rails']],
];
$yaml = Yaml::fromArray($employees );
```

That will return the following

```
- name: Jim
  skills:
    - php
    - mysql
    - puppeteer
- name: Amy
  skills:
    - ruby
    - ruby on rails
```

Here is an example converting a record using the Bookmark model

```
 $bookmark = $this->Bookmark->get(1,[
            'associated'=>[
                'User','Tag'
                ]
            ]);
$string = Yaml::fromArray($bookmark->toArray());
```

This will create the following YAML string:

```
id: 1
user_id: 1
title: OriginPHP
description: The PHP framework for rapidly building scalable web applications.
url: https://www.originphp.com
category: Computing
created: 2018-12-28 15:25:34
modified: 2019-05-02 13:08:44
user:
  id: 1
  name: Demo User
  email: demo@example.com
  password: $2y$10$/clqxdb.aWe43VXDUn8tA.yxKbWHZT3rN7gqITFaj32PZHI3.DkzW
  dob: 1999-12-28
  created: 2018-12-28 15:24:13
  modified: 2018-12-28 15:24:13
tags:
  - id: 1
    title: Framework
    created: 2019-03-07 18:45:43
    modified: 2019-03-07 18:45:43
    bookmarksTag:
      bookmark_id: 1
      tag_id: 1
  - id: 2
    title: PHP
    created: 2019-03-07 18:45:43
    modified: 2019-03-07 18:45:43
    bookmarksTag:
      bookmark_id: 1
      tag_id: 2
tag_string: Framework,PHP
```

Read YAML
---------

[](#read-yaml)

To create an array from a YAML string

```
$employee =  'name: Tom
position: developer
skills:
    - php
    - mysql
    - js
addresses:
    - street: 14 some road
      city: london
    - street: 21 some avenue
      city: leeds
summary:
    this is a text description
    for this employee';
$array = Yaml::toArray($employee);
/*
Array
(
    [name] => Tom
    [position] => developer
    [skills] => Array
        (
            [0] => php
            [1] => mysql
            [2] => js
        )

    [addresses] => Array
        (
            [0] => Array
                (
                    [street] => 14 some road
                    [city] => london
                )

            [1] => Array
                (
                    [street] => 21 some avenue
                    [city] => leeds
                )

        )

    [summary] => this is a text description for this employee
)
*/
```

###  Health Score

25

—

LowBetter than 35% of packages

Maintenance0

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~47 days

Recently: every ~6 days

Total

11

Last Release

1979d ago

Major Versions

1.2.1 → 2.0.02021-01-04

PHP version history (3 changes)1.0.0PHP ^7.2.0

1.2.1PHP &gt;=7.2.0

2.0.0PHP &gt;=7.3.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/7e8a821333d9c7b7bc2ad3d164d142f65cd3912dea78033d31f76b0f19ba8a0c?d=identicon)[originphp](/maintainers/originphp)

---

Top Contributors

[![jamielsharief](https://avatars.githubusercontent.com/u/20553479?v=4)](https://github.com/jamielsharief "jamielsharief (24 commits)")

---

Tags

parseryamloriginPHP

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/originphp-yaml/health.svg)

```
[![Health](https://phpackages.com/badges/originphp-yaml/health.svg)](https://phpackages.com/packages/originphp-yaml)
```

###  Alternatives

[nikic/php-parser

A PHP parser written in PHP

17.4k954.1M2.4k](/packages/nikic-php-parser)[doctrine/lexer

PHP Doctrine Lexer parser library that can be used in Top-Down, Recursive Descent Parsers.

11.2k942.7M157](/packages/doctrine-lexer)[erusev/parsedown

Parser for Markdown.

15.1k156.8M855](/packages/erusev-parsedown)[masterminds/html5

An HTML5 parser and serializer.

1.8k269.7M309](/packages/masterminds-html5)[jms/metadata

Class/method/property metadata management in PHP

1.8k160.2M96](/packages/jms-metadata)[matomo/device-detector

The Universal Device Detection library, that parses User Agents and detects devices (desktop, tablet, mobile, tv, cars, console, etc.), clients (browsers, media players, mobile apps, feed readers, libraries, etc), operating systems, devices, brands and models.

3.5k26.4M169](/packages/matomo-device-detector)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
