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. maxbeckers/php-yaml-parser

ActiveLibrary

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

Parse YAML with PHP

0.1.2(6mo ago)213[1 issues](https://github.com/maxbeckers/php-yaml-parser/issues)MITPHPPHP &gt;=8.2CI passing

Since Nov 19Pushed 2mo 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 1mo ago

READMEChangelog (3)Dependencies (2)Versions (5)Used By (0)

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 parser follows a multi-stage pipeline:

```
Input (string/file)
    ↓
Lexer (tokenization)
    ↓
Parser (AST building)
    ↓
Tag Processor (allows also custom tag handling)
    ↓
Resolver (anchors/aliases)
    ↓
Resolver (merge keys)
    ↓
Serializer (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
- Code cleanup and refactoring
- Additional unit tests for edge cases
- Implement parsing for currently skipped test cases
- Optimize handling for special cases
- Add configurable options for parsing behavior
- 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 124/402 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

32

—

LowBetter than 72% of packages

Maintenance67

Regular maintenance activity

Popularity8

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity40

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

Total

3

Last Release

180d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/784c9320748c5fd9fc27bd716af8d2fdb735ddd6b465a6ba330fcbf36271fe9c?d=identicon)[maxbeckers](/maintainers/maxbeckers)

---

Top Contributors

[![maxbeckers](https://avatars.githubusercontent.com/u/11738128?v=4)](https://github.com/maxbeckers "maxbeckers (22 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)
```

PHPackages © 2026

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