PHPackages                             maxbeckers/php-yaml-parser - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. maxbeckers/php-yaml-parser

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

maxbeckers/php-yaml-parser
==========================

Parse YAML with PHP

0.3.2(3w ago)31021MITPHPPHP &gt;=8.2CI passing

Since Nov 19Pushed 1mo agoCompare

[ Source](https://github.com/maxbeckers/php-yaml-parser)[ Packagist](https://packagist.org/packages/maxbeckers/php-yaml-parser)[ RSS](/packages/maxbeckers-php-yaml-parser/feed)WikiDiscussions master Synced today

READMEChangelog (7)Dependencies (5)Versions (8)Used By (1)

YAML Parser Library
===================

[](#yaml-parser-library)

A PHP implementation of a YAML parser built for learning and understanding the YAML 1.2 specification.

Features
--------

[](#features)

- **Extensible Tag System**: Define and register custom tags with ease
- **Anchor and Alias Support**: Automatic resolution of anchors and aliases
- **Error Handling**: Detailed error messages with line and column information
- **Merge Key Support**: Implements merge keys for mappings even though not defined in YAML 1.2

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

[](#installation)

```
composer require maxbeckers/php-yaml-parser
```

Usage
-----

[](#usage)

### Basic Parsing

[](#basic-parsing)

```
use MaxBeckers\YamlParser\YamlParser;

$yamlParser = new YamlParser();
$data = $yamlParser->parseFile('config.yaml');
```

### Custom Tag Handlers

[](#custom-tag-handlers)

```
// Register custom tag handler for environment variables
$yamlParser->getTagRegistry()->register(
    new CustomTagHandler('!env', function($value) {
        return getenv($value) ?: $value;
    })
);

// Use in YAML
// database_host: !env DATABASE_HOST
```

Architecture
------------

[](#architecture)

The library follows a multi-stage pipeline:

```
Input (string/file)
    ↓
Lexer (tokenization)
    ↓
Parser (AST building, implicit tag resolution)
    ↓
Tag Resolver (explicit tag handling, extensible with custom tags)
    ↓
Resolver (anchors/aliases)
    ↓
Resolver (merge keys)
    ↓
Constructor (to PHP ArrayObject)

```

Background
----------

[](#background)

I have written this YAML parser library in PHP to learn more about YAML. Already a lot of months ago someone said to me "YAML is a weird beast", that triggered my curiosity to learn more about it. So i started to read the YAML specification and implement a parser for it. While implementing the parser i found out that YAML is indeed a weird beast. There are many edge cases and special cases that make it hard to implement a fully compliant parser. Also the specification itself is not always clear and sometimes even contradictory. So i had to make some decisions on how to handle certain cases. I tried to follow the specification as closely as possible, but there are some cases where i had to deviate from it. For example, the specification does not define how to handle merge keys in YAML 1.2, but i decided to implement it anyway, because it is a useful feature. This means that this library is not fully compliant with the YAML specification and probably never will be 100% compliant. Use at your own risk. But i make it publicly available in the hope that it might be useful to someone.

Todos
-----

[](#todos)

- Performance optimizations for large YAML files
- Add configurable options for parsing behavior (e.g. strict mode, return plain arrays instead of ArrayObject)
- Improve metadata handling for mappings and sequences
- Make all tests from the [YAML test suite](https://github.com/yaml/yaml-test-suite.git) pass (currently 95 are skipped)

Contributing
------------

[](#contributing)

Contributions are welcome! Please feel free to submit issues or pull requests.

Acknowledgments
---------------

[](#acknowledgments)

Built with reference to the [YAML 1.2.2 Specification](https://yaml.org/spec/1.2.2/).

###  Health Score

43

↑

FairBetter than 89% of packages

Maintenance94

Actively maintained with recent releases

Popularity17

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 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 ~40 days

Recently: every ~50 days

Total

6

Last Release

23d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/11738128?v=4)[Max Beckers](/maintainers/maxbeckers)[@maxbeckers](https://github.com/maxbeckers)

---

Top Contributors

[![maxbeckers](https://avatars.githubusercontent.com/u/11738128?v=4)](https://github.com/maxbeckers "maxbeckers (27 commits)")

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/maxbeckers-php-yaml-parser/health.svg)

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

###  Alternatives

[assisted-mindfulness/naive-bayes

Naive Bayes classifier algorithm

45536.2k](/packages/assisted-mindfulness-naive-bayes)[bobey/geoip2-geolite2-composer

This tiny repository aims to provide an easy solution to require GeoIP2 / GeoLite2 databases inside your project using composer.

17896.8k1](/packages/bobey-geoip2-geolite2-composer)[sniccowp/php-scoper-wordpress-excludes

A list of all WordPress core classes, functions and constants. Meant to be used with the PHP-Scoper exclusion functionality.

16179.2k6](/packages/sniccowp-php-scoper-wordpress-excludes)[mage-os/mageos-async-events

An event-driven flexible async events module that allows you to process any event asynchronously.

3223.5k5](/packages/mage-os-mageos-async-events)[that0n3guy/transliteration

Transliteration provides one-way string transliteration (romanization) and cleans text by replacing unwanted characters.

12101.6k4](/packages/that0n3guy-transliteration)

PHPackages © 2026

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