PHPackages                             horde/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. horde/yaml

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

horde/yaml
==========

Roundtrip-capable YAML parsing and writing library

v3.0.1(1mo ago)13.3k↑125.6%54BSD-2-ClausePHPPHP ^8.2

Since Jan 9Pushed 2mo ago5 watchersCompare

[ Source](https://github.com/horde/Yaml)[ Packagist](https://packagist.org/packages/horde/yaml)[ Docs](https://www.horde.org/libraries/Horde_Yaml)[ RSS](/packages/horde-yaml/feed)WikiDiscussions FRAMEWORK\_6\_0 Synced 1mo ago

READMEChangelog (5)Dependencies (9)Versions (22)Used By (4)

horde/yaml
==========

[](#hordeyaml)

Pedantic, lossless and pure-PHP YAML 1.2 parser with byte-identical round-trip.

This library ships with two layers:

- **Legacy `Horde_Yaml`**: array-only loader/dumper kept for backwards compatibility with existing Horde components.
- **Modern `Horde\Yaml\Document`**: comment-preserving load/edit/dump pipeline with a public AST, anchor and alias support, and atomic file writes. Targets configuration files like `.horde.yml` that must round-trip through human and machine edits.

The two layers live side by side. New code should use the document layer.

Highlights
----------

[](#highlights)

- **100% YAML 1.2 conformance.** All 391 cases from the upstream yaml-test-suite pass: every spec example loads as the spec says it should, every malformed input is rejected.
- **Byte-identical round-trip.** Loading a source file and dumping it back without mutation produces the exact same bytes. Comments, blank lines, end-of-line spacing, quoting style, and flow layout all survive.
- **Comments and trivia are first-class AST nodes.** Standalone comments live as siblings of map entries and sequence items. EOL comments are properties of their entry. Stream- and document-level trivia have their own slots. Position-based insert / remove / replace is supported on every container.
- **Strict by default, lenient on opt-in.** `LeniencyPolicy::strictYaml12()`is the conformance baseline. `LeniencyPolicy::hordeCompat()` keeps the historical tolerance for existing `.horde.yml` files (legacy booleans, malformed directives, undefined tag handles, etc.).
- **Pure PHP, no extensions.** ext-mbstring is the only requirement. No libyaml, no shell-out.

### Conformance table

[](#conformance-table)

SuiteCasesPassyaml-test-suite (YAML 1.2 reference)391391 (100%)Round-trip probe (comments, whitespace, trivia)1515 (100%)Unit tests14011401 (100%)Requirements
------------

[](#requirements)

- PHP 8.2 or later (8.1 for the legacy parser)
- ext-mbstring

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

[](#installation)

```
composer require horde/yaml
```

Document layer at a glance
--------------------------

[](#document-layer-at-a-glance)

```
use Horde\Yaml\Document\YamlFileLoader;
use Horde\Yaml\Document\YamlFileDumper;

$loader = new YamlFileLoader();
$dumper = new YamlFileDumper();

$stream = $loader->load('config.yml');
$doc = $stream->document(0);

$doc->setEntry('name', 'kronolith');
$doc->setEntry('version', '6.0.0');

$dumper->dump($stream, 'config.yml');
```

A clean round-trip (load and dump without mutation) reproduces the source byte-for-byte. After mutation, every untouched part of the file stays exactly as it was: comments, blank lines, the spacing before EOL comments, single vs double quotes, and the layout of multi-line flow collections. See `doc/examples/byte-identical-roundtrip.php` for a runnable proof.

To insert a comment at a specific position, use the container's positional API:

```
$authors->insertCommentBefore(2, '# Joined the project in 2026.');
```

See `doc/examples/splice-comment.php`.

See `doc/USAGE.md` for the full API and `doc/examples/` for runnable snippets.

Documentation
-------------

[](#documentation)

- `doc/USAGE.md`: document layer API guide
- `doc/UPGRADING.md`: migration notes from `Horde_Yaml`
- `doc/examples/`: runnable PHP snippets
- `doc/changelog.yml`: release history

Testing
-------

[](#testing)

```
phpunit                                 # unit + integration suites
phpunit -c phpunit-perf.xml.dist        # performance gates
```

The performance suite expects a snapshotted `.horde.yml` corpus at `test/fixtures/perf/horde-yml-corpus/`. Refresh it from a local component checkout via:

```
./scripts/snapshot-horde-yml-corpus.sh
```

Conformance against the upstream yaml-test-suite is opt-in; run `git submodule update --init` to fetch the cases, then re-run the default suite. Triage status lives in `test/fixtures/conformance/yaml-test-suite-status.php`.

License
-------

[](#license)

LGPL-2.1. See `LICENSE`.

###  Health Score

60

—

FairBetter than 98% of packages

Maintenance88

Actively maintained with recent releases

Popularity27

Limited adoption so far

Community30

Small or concentrated contributor base

Maturity85

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 79.7% 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 ~300 days

Recently: every ~32 days

Total

15

Last Release

36d ago

Major Versions

2.0.7 → 3.0.0alpha22021-02-24

2.1.0 → v3.0.0alpha42022-08-18

PHP version history (6 changes)2.0.3PHP &gt;=5.3.0,&lt;=6.0.0alpha1

2.0.5PHP &gt;=5.3.0,&lt;=8.0.0alpha1

2.0.6PHP ^5.3 || ^7

3.0.0alpha2PHP ^7

v3.0.0alpha4PHP ^7.4 || ^8

v3.0.0RC1PHP ^8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/c943a083635c28520599075eaea7ede2d743b7697b76e84d6bdc37e52cc8249b?d=identicon)[yunosh](/maintainers/yunosh)

![](https://www.gravatar.com/avatar/c931cd02664859360478593450d6c473a05bb12b209dfacfc534cd13257cc7ef?d=identicon)[ralflang](/maintainers/ralflang)

![](https://www.gravatar.com/avatar/e4f6c6771993db2ed500959b42353f6cf6a2ca0406d9617f7ae680f4504faa4a?d=identicon)[horde](/maintainers/horde)

![](https://www.gravatar.com/avatar/a7767adb66b45f2f05bcd44d49bc4e67efacd9ce05b161ce2d481d5dd6af025c?d=identicon)[mrubinsk](/maintainers/mrubinsk)

![](https://www.gravatar.com/avatar/816e2b926f25f8cd2939054c7a7173011b4303d690e25ab61bf33cf8c7cf71ae?d=identicon)[tdannhauer](/maintainers/tdannhauer)

---

Top Contributors

[![yunosh](https://avatars.githubusercontent.com/u/379318?v=4)](https://github.com/yunosh "yunosh (145 commits)")[![ralflang](https://avatars.githubusercontent.com/u/646976?v=4)](https://github.com/ralflang "ralflang (26 commits)")[![mrubinsk](https://avatars.githubusercontent.com/u/66822?v=4)](https://github.com/mrubinsk "mrubinsk (5 commits)")[![slusarz](https://avatars.githubusercontent.com/u/381003?v=4)](https://github.com/slusarz "slusarz (3 commits)")[![wrobel](https://avatars.githubusercontent.com/u/10232?v=4)](https://github.com/wrobel "wrobel (2 commits)")[![KarimGeiger](https://avatars.githubusercontent.com/u/2329930?v=4)](https://github.com/KarimGeiger "KarimGeiger (1 commits)")

---

Tags

compliantlosslessroundtrip

### Embed Badge

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

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

###  Alternatives

[sauladam/shipment-tracker

Parses tracking information for several carriers, like UPS, USPS, DHL and GLS by simply scraping the data. No need for any kind of API access.

9845.4k](/packages/sauladam-shipment-tracker)[jstewmc/rtf

Read and write Rich Text Format (RTF) documents with PHP

46164.0k6](/packages/jstewmc-rtf)[gajus/paggern

Pattern interpreter for generating random strings.

3046.0k1](/packages/gajus-paggern)[tcds-io/php-jackson

A lightweight, flexible object serializer for PHP, inspired by FasterXML/jackson

113.4k10](/packages/tcds-io-php-jackson)

PHPackages © 2026

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