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

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

atk14/mini-yaml
===============

Minimalistic YAML loader and dumper for PHP supporting nested structures, block scalars and PHP template evaluation

v1.1(1mo ago)07.4k↑14.8%3MITPHPPHP &gt;=5.6.0CI passing

Since Jan 4Pushed 1mo ago2 watchersCompare

[ Source](https://github.com/atk14/MiniYaml)[ Packagist](https://packagist.org/packages/atk14/mini-yaml)[ Docs](https://github.com/atk14/MiniYaml)[ RSS](/packages/atk14-mini-yaml/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependencies (2)Versions (4)Used By (3)

MiniYAML
========

[](#miniyaml)

[![Tests](https://github.com/atk14/MiniYaml/actions/workflows/tests.yml/badge.svg)](https://github.com/atk14/MiniYaml/actions/workflows/tests.yml)

MiniYAML is a minimalistic YAML loader and dumper for PHP. It handles the subset of YAML commonly used for configuration files and API responses.

**Why MiniYAML?**

- **Single file, zero dependencies.** Drop `miniyaml.php` into your project and you are done — no Composer, no autoloader, no transitive dependencies.
- **Tiny footprint.** The entire implementation is ~350 lines of straightforward PHP.
- **PHP template evaluation.** The built-in `InterpretPHP()` method lets you embed `` tags directly in YAML, making it easy to build environment-specific configuration without a separate templating step. No other mainstream YAML library offers this.
- **Readable API.** Three static methods — `Load()`, `Dump()`, `InterpretPHP()` — cover all common use cases without configuration overhead.
- **Runs on PHP 5.6 and up.** Works on legacy hosting and old codebases where modern libraries have already dropped support.

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

[](#installation)

```
composer require atk14/mini-yaml

```

Usage
-----

[](#usage)

### Load

[](#load)

```
$ar = miniYAML::Load($yaml_string);
```

Options:

OptionTypeDefaultDescription`nullable`bool`true`Treat `null` and `NULL` as PHP `null``interpret_php`bool`false`Evaluate PHP tags (``) embedded in the YAML string`values`array`[]`Variables made available when `interpret_php` is enabled```
// Disable null handling — "null" is kept as a plain string
$ar = miniYAML::Load($yaml_string, ["nullable" => false]);

// Evaluate embedded PHP
$yaml = miniYAML::Load($template, [
    "interpret_php" => true,
    "values" => ["domain" => "example.com"],
]);
```

### Dump

[](#dump)

```
$yaml = miniYAML::Dump($array);
```

Options:

OptionTypeDefaultDescription`nullable`bool`true`Dump PHP `null` as `NULL`; when `false`, dumps as empty string `""````
$yaml = miniYAML::Dump($array, ["nullable" => false]);
```

Supported YAML features
-----------------------

[](#supported-yaml-features)

**Load and Dump:**

- Hash (associative) arrays: `key: value`
- Indexed (list) arrays: `- item`
- Nested structures of arbitrary depth
- Empty arrays: `[]`
- Quoted strings: `"value"` and `'value'`
- `null` / `NULL` values (controlled by the `nullable` option)
- Comments: lines starting with `#`

**Load only:**

- Literal block scalars (`|`) — newlines preserved
- Folded block scalars (`>`) — newlines replaced with spaces

**Dump only:**

- Strings containing newlines are automatically serialized as literal block scalars (`|`)
- Strings requiring escaping (colons, special characters, YAML keywords, …) are wrapped in double quotes

Example
-------

[](#example)

```
$yaml = '
---
status: success
message: Ok
data:
  domain: example.com
  admin:
  - Alice
  - Bob
  description: |
    First line.
    Second line.
';

$ar = miniYAML::Load($yaml);
// [
//   "status"  => "success",
//   "message" => "Ok",
//   "data"    => [
//     "domain"      => "example.com",
//     "admin"       => ["Alice", "Bob"],
//     "description" => "First line.\nSecond line.",
//   ]
// ]

echo miniYAML::Dump($ar);
```

Limitations
-----------

[](#limitations)

The following YAML features are **not** supported:

- Multiline plain scalars (without `|` or `>`)
- Anchors and aliases (`&`, `*`)
- Explicit type tags (`!!str`, `!!int`, …)
- Flow mappings and sequences (`{…}`, `[…]`) — except empty array `[]`
- Documents with a common base indentation on all lines

MiniYAML is well-suited for YAML you write and control yourself. If the input comes from an external tool or another language, it may use syntax that MiniYAML silently misparses or ignores.

Alternatives
------------

[](#alternatives)

If MiniYAML does not cover your use case, consider these alternatives:

LibraryNotes[symfony/yaml](https://github.com/symfony/yaml)Pure PHP, covers most of YAML 1.2. The standard choice for full YAML support; works standalone without the Symfony framework.[ext-yaml](https://pecl.php.net/package/yaml)PHP extension wrapping libyaml (C). Fastest option, full YAML 1.1 compliance. Requires server-level installation.[nette/neon](https://github.com/nette/neon)Pure PHP, implements NEON — a YAML-like format with PHP-native types. Not YAML, but a comfortable alternative if you control both ends.Testing
-------

[](#testing)

```
composer update --dev
./vendor/bin/run_unit_tests test

```

License
-------

[](#license)

MiniYAML is free software distributed [under the terms of the MIT license](http://www.opensource.org/licenses/mit-license)

###  Health Score

47

—

FairBetter than 93% of packages

Maintenance91

Actively maintained with recent releases

Popularity23

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity51

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

Total

2

Last Release

48d ago

PHP version history (2 changes)v1.0PHP &gt;=5.3.0

v1.1PHP &gt;=5.6.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/974278?v=4)[Jaromir Tomek](/maintainers/yarri)[@yarri](https://github.com/yarri)

---

Top Contributors

[![yarri](https://avatars.githubusercontent.com/u/974278?v=4)](https://github.com/yarri "yarri (44 commits)")

---

Tags

yaml

### Embed Badge

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

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

###  Alternatives

[jms/metadata

Class/method/property metadata management in PHP

1.8k160.2M98](/packages/jms-metadata)[nette/neon

🍸 Nette NEON: encodes and decodes NEON file format.

93866.0M396](/packages/nette-neon)[mustangostang/spyc

A simple YAML loader/dumper class for PHP

73243.7M208](/packages/mustangostang-spyc)[hassankhan/config

Lightweight configuration file loader that supports PHP, INI, XML, JSON, and YAML files

1.0k13.8M187](/packages/hassankhan-config)[spatie/yaml-front-matter

A to the point yaml front matter parser

3482.0M100](/packages/spatie-yaml-front-matter)[pragmarx/yaml

Load your Laravel config files using yaml

1152.8M29](/packages/pragmarx-yaml)

PHPackages © 2026

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