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

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

dallgoot/yaml
=============

Provides loader, dumper and an API for YAML content. Loader builds to equivalent data types in PHP 8.x

1.0.1(11mo ago)43185.8k↑29.9%11[1 PRs](https://github.com/dallgoot/yaml/pulls)6Apache-2.0PHPPHP &gt;=8.1CI failing

Since Dec 5Pushed 11mo ago4 watchersCompare

[ Source](https://github.com/dallgoot/yaml)[ Packagist](https://packagist.org/packages/dallgoot/yaml)[ Docs](https://github.com/dallgoot/yaml)[ GitHub Sponsors](https://github.com/dallgoot)[ RSS](/packages/dallgoot-yaml/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (5)Versions (7)Used By (6)

Dallgoot : YAML library for PHP - Beta
======================================

[](#dallgoot--yaml-library-for-php---beta)

[![Build Status](https://camo.githubusercontent.com/738f55f48ddb4cfe77fcec45cd9e79719872d435195c007c424245a54a06ba18/68747470733a2f2f6170692e7472617669732d63692e636f6d2f64616c6c676f6f742f79616d6c2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/dallgoot/yaml) [![PHP from Packagist](https://camo.githubusercontent.com/de0befbaf4c996dcc9e3782cc6bb7051e38538c1d0d218789bd337c88716d2fb/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f64616c6c676f6f742f79616d6c)](https://packagist.org/packages/dallgoot/yaml) [![Packagist](https://camo.githubusercontent.com/307fee6f6126f6e86af8d73cb3e072f8eaf4eacab5428e3ccbd36a7a65239149/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f64616c6c676f6f742f79616d6c)](https://packagist.org/packages/dallgoot/yaml)[![Maintainability](https://camo.githubusercontent.com/db6c52f689af4efae2bf1c4ea7844d7e009e89a23057e96f61e515a218486634/68747470733a2f2f6170692e636f6465636c696d6174652e636f6d2f76312f6261646765732f64666165346238653636356131643732386533642f6d61696e7461696e6162696c697479)](https://codeclimate.com/github/dallgoot/yaml/maintainability) [![Scrutinizer Code Quality](https://camo.githubusercontent.com/4cf91ee670ed47d3c616618185bd85d7be38584c92cca7d37ecee11881ab842b/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f64616c6c676f6f742f79616d6c2f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/dallgoot/yaml/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/427c50ee4de2b0e741f68dbc8131d40d4b427c04417bb51688129431dda12b54/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f64616c6c676f6f742f79616d6c2f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/dallgoot/yaml/?branch=master)

PHP library to load and parse YAML file to coherent PHP datatypes equivalent

[![Dallgoot/Yaml Library](dallgoot_yaml.png)](dallgoot_yaml.png)

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

[](#installation)

- Dependencies are only useful for building documentation or for code contribution, so the "--update-no-dev" prevent from downloading and managing packages that you probably won't use.

You first need [Composer](https://getcomposer.org/) and PHP ^8.1.14

```
composer require --update-no-dev dallgoot/yaml
```

Usage
-----

[](#usage)

See [examples folder](./examples)

Features
--------

[](#features)

- *consistent* PHP datatypes :
    - object for mappings
    - array for sequences
    - common scalars : string, integer, float, INF, NAN
    - JSON, DateTime(option), etc.
- specific types (objects)
    - **YamlObject** for each Yaml content (multi-documents YAML is an array of YamlObject)
    - **Compact** for compact/short YAML syntax
    - **Tagged** object when tag is not determinable
- recover from some parsing errors
- tolerant to tabulations
- debug levels :
    - 1 : print each line Node Type class and exit
    - 2 : print Loader global tree structure and exit
    - 3 : print each document NodeList and exit

Support
-------

[](#support)

- YAML specifications [version 1.2](http://yaml.org/spec/1.2/spec.html)
- multi-line values (simple|double quoted or not, compact mapping|sequence or JSON)
- multiple documents in a content (file or string)
- compact syntax for mappings and sequences
- comments (not yet implemented)
- references (option : enabled by default)
- tags with behaviour customization (overriding for common(CoreSchema), or specifying for custom) via implementing Tag/SchemaInterface.

What's different from other PHP Yaml libraries ?
------------------------------------------------

[](#whats-different-from-other-php-yaml-libraries-)

YAML version supportedcoherent data typesmultiple documentsJSON format validationcomplex mappingreal reference behaviourcustom tags handling[Symfony Yaml](https://symfony.com/doc/current/components/yaml.html)1.2❌❌❌❌❌✔️[php-yaml](https://pecl.php.net/package/yaml)1.1❌✔️❌❌❌✔️[syck](http://pecl.php.net/package/syck)1.0❌❌❌❌❌❌[spyc](https://github.com/mustangostang/spyc)1.0❌❌❌❌❌❌**Dallgoot/Yaml**1.2✔️✔️✔️✔️✔️✔️- coherent data types (see [coherence.md](./documentation/coherence.md) for explanations)
- JSON format validation (Option, Note: if valid as per PHP function [json\_encode](https://www.php.net/manual/en/function.json-encode.php))
- complex mapping (Note: keys are JSON formatted strings)
- real reference behaviour : changing reference value modify other reference calls

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

[](#contributing)

Only contributions concerning bug fixes will be review ATM. Requests for features will be dealt with after reading/writing YAML is considered bug free (and al current Options are implemented)

ToDo
----

[](#todo)

- Code coverage : target 100%
- Benchmarks against other libs

Improvements
------------

[](#improvements)

- Examples of each function of the API
- implement specific unit test for each YAML spec. invalid cases (what must not happen)
- DUMPER:
    - implement/verify Dumper::Options
- better/more precise errors identification (Yaml validation) with explanation in YAML content
- Unicode checking (???)
- OPTION : parse dates as PHP DateTime object
- OPTION: Force renaming key names that are not valid PHP property name
- TAG : function for 'php/object' that provides the correct namespace to build
- NEON compatibility???
- make immutable YamlObject

Performances
------------

[](#performances)

```
- TBD
- improved memory using SplFixedArray instead of regular arrays where possible

```

Sponsor
-------

[](#sponsor)

That is greatly appreciated : [![Buy Me A Coffee](https://camo.githubusercontent.com/0cf29a542375e1a46e84d8bf5805a4e5c0a6ee98b6547ccdc0c55eed49d99c69/68747470733a2f2f63646e2e6275796d6561636f666665652e636f6d2f627574746f6e732f76322f64656661756c742d79656c6c6f772e706e67)](https://www.buymeacoffee.com/m23aurqwP)

Thanks
------

[](#thanks)

-
-
- [Symfony Yaml](https://symfony.com/doc/current/components/yaml.html)

###  Health Score

52

—

FairBetter than 96% of packages

Maintenance51

Moderate activity, may be stable

Popularity48

Moderate usage in the ecosystem

Community25

Small or concentrated contributor base

Maturity70

Established project with proven stability

 Bus Factor1

Top contributor holds 96.9% 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 ~403 days

Recently: every ~500 days

Total

6

Last Release

342d ago

Major Versions

0.9.1.2 → 1.0.0.02024-10-18

PHP version history (3 changes)v0.1.1PHP &gt;=7.1.10

0.9.1.2PHP &gt;=8.1.14

1.0.0.0PHP &gt;=8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/6eca43a0f2bcaef5cc6a8afa9e50a8415cbf8177c8d3b5ba175804344a85a7cb?d=identicon)[dallgoot](/maintainers/dallgoot)

---

Top Contributors

[![dallgoot](https://avatars.githubusercontent.com/u/26066516?v=4)](https://github.com/dallgoot "dallgoot (222 commits)")[![scrutinizer-auto-fixer](https://avatars.githubusercontent.com/u/6253494?v=4)](https://github.com/scrutinizer-auto-fixer "scrutinizer-auto-fixer (3 commits)")[![WengerK](https://avatars.githubusercontent.com/u/1841592?v=4)](https://github.com/WengerK "WengerK (2 commits)")[![giuspe](https://avatars.githubusercontent.com/u/1685943?v=4)](https://github.com/giuspe "giuspe (1 commits)")[![loneregister](https://avatars.githubusercontent.com/u/6249947?v=4)](https://github.com/loneregister "loneregister (1 commits)")

---

Tags

datatypesphpphp-libraryyamlyaml-parserparseryamlwriterreader

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[bcncommerce/json-stream

A bundle of tools to work with JSON in PHP

642.2M3](/packages/bcncommerce-json-stream)[veewee/xml

XML without worries

1835.9M29](/packages/veewee-xml)

PHPackages © 2026

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