PHPackages                             secondparty/dipper - 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. secondparty/dipper

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

secondparty/dipper
==================

A fast YAML parser that parses for the more commonly-used subset of YAML’s v1.0 and v1.2 specs.

v0.5.2(10y ago)202.5k↓100%2[2 PRs](https://github.com/secondparty/dipper/pulls)1BSD-3-ClausePHPPHP &gt;=5.3.0

Since Feb 25Pushed 9y ago7 watchersCompare

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

READMEChangelog (8)DependenciesVersions (6)Used By (1)

Dipper
======

[](#dipper)

[![Build Status](https://camo.githubusercontent.com/9036189c6b2004e991d122355c3bb095287e036b53cd38c70c0391ed39dbb6b1/68747470733a2f2f7472617669732d63692e6f72672f7365636f6e6470617274792f6469707065722e737667)](https://travis-ci.org/secondparty/dipper)

Dipper is fast YAML parser that parses for the more commonly-used subset of YAML’s v1.0 and v1.2 official specifications. It is being made freely available for use in personal or commercial projects under the BSD 3-clause license.

Philosophy
----------

[](#philosophy)

One has to question themselves when they sit down to create a YAML parser considering there are already a number of nice solutions out there. There’s SPYC, which does a wonderful job parsing for YAML 1.0, and Symfony also has a YAML parser that parses to YAML 1.2 specifications. Neither project claims to completely support all aspects of the specs that they repsectively parse for (the specs *are* quite large and in-depth), but they both support a large subset of the defined features.

But it occurred to us that we rarely use most of those features. Perhaps we’re not YAML power-users, but the subset we find ourselves using mostly is the same YAML that those libraries use when they convert straight PHP back to YAML. Mostly: normal key/value pairs (strings, scalars, numbers &amp; booleans), lists, and maps.

Part of YAML’s design was defining a somewhat complex-to-parse syntax in exchange for simple (yet powerful) formatting for human readability. We found that a lot of the parsing complexity came in supporting features above and beyond the simple subset of YAML that we actually use.

And thus, Dipper was born. It’s built for speed, micro-optimized to parse the parts of YAML that we actually use, and nothing more.

### Results

[](#results)

We’ve run a couple of benchmarks to make sure that Dipper *is* quick and thus, is worth releasing, and here is what we found. Keep in mind that we’re not scientists, but are here as an example of comparison.

```
  Parser    |  YAML->PHP  |  PHP->YAML
------------+-------------+-------------
  SPYC      |    ~22ms    |    ~17ms
  Symfony   |    ~24ms    |    ~12ms
  Dipper    |    ~10ms    |    ~ 3ms

```

We ran the same 500-line YAML file through each of the parsers described in this document 250 times. We then took the average time for each parser to parse the document to get the `YAML->PHP` time. Next, we parsed the 500-line YAML file into PHP and then converted that back into YAML 250 times per parser. The average time to convert it back are the `PHP->YAML` times.

As you can see by these times, Dipper comes out ahead in both parsing YAML and building it back up.

Usage
-----

[](#usage)

Dipper performs two tasks: it converts well-formed YAML into PHP, and it converts PHP into well-formed YAML.

```
// include Dipper and ready it for use
require('Dipper.php');
use secondparty\Dipper\Dipper as Dipper;

// now you can convert YAML into PHP
$php = Dipper::parse($yaml);

// or you can convert PHP into YAML
$yaml = Dipper::make($php);
```

That’s all there is to it.

What It Will Parse
------------------

[](#what-it-will-parse)

Below is a complete list of the subset of YAML that Dipper will parse.

### Strings

[](#strings)

```
string: this is a string
single_quoted_string: 'this is a single-quoted string'
double_quoted_string: "this is a double-quoted string"
string_with_single_quote: this's a string with a single quote
string_with_colon: 'this is a string: containing a colon'
string_with_comma: F j, Y
quoted_number: "120"
quoted_true: "true"
quoted_false: "false"
url: http://something.com
```

### Scalars

[](#scalars)

```
literal_scalar: |
  This is a scalar
  that will preserve
  its line breaks.

folding_scalar: >
  This is a scalar
  that will fold up
  line breaks.
```

### Numbers

[](#numbers)

```
integer: 42            # becomes an integer
float: -12.12          # becomes a float
octal: 0755            # YAML 1.0-style, becomes an integer, converted from octal
also_octal: 0o755      # YAML 1.2-style, becomes an integer, converted from octal
hex: 0xff              # becomes an integer, converted from hexadecimal
infinite: (inf)        # YAML 1.0-style, becomes INF, PHP constant for infinity
minus_inf: (-inf)      # YAML 1.0-style, becomes -INF, PHP constant for negative infinity
not_a_number: (NaN)    # YAML 1.0-style, becomes NAN, PHP constant for not-a-number
also_infinity: .inf    # YAML 1.2-style, becomes INF, PHP constant for infinity
also_minus_inf: -.inf  # YAML 1.2-style, becomes -INF, PHP constant for negative infinity
also_nan: .NaN         # YAML 1.2-style, becomes NAN, PHP constant for not-a-number
```

### Booleans &amp; Null Values

[](#booleans--null-values)

```
bool_true: true        # becomes true (as a boolean)
bool_false: false      # becomes false (as a boolean)
null_value: null       # becomes a PHP null value
shorthand_null: ~      # becomes a PHP null value
empty_value:           # becomes a PHP null value
```

### Lists

[](#lists)

```
regular_list:
  - first item
  - second item
  - third item

shorthand_list: [ first item, second item, third item ]
```

### Maps

[](#maps)

```
regular_map:
  one: first
  two: second

shorthand_map: { one: first, two: second }
```

### Combinations of These

[](#combinations-of-these)

In addition to each of these elements individually, you can also combine and nest them as you’d expect to create more complex structures. Shorthand versions of lists and maps shouldn’t nest other lists or maps.

What it Makes
-------------

[](#what-it-makes)

Below is a complete list of the PHP that Dipper will build from the YAML passed to it.

- strings
- integers
- floats (including any float constants)
- booleans
- null values
- empty strings
- sequential arrays (into lists)
- associative arrays (into maps)
- objects (if they’ve implemented `__toString`)

Notes
-----

[](#notes)

- Like SPYC and Symfony’s code, Dipper also supports the `syck` YAML parsing extension for PHP if it’s installed and enabled on your server. This moves YAML parsing down to the system level, resulting in parsing that is much, much faster than what straight PHP code itself can deliver.
- In addition to YAML, we also really like Markdown. To better support Markdown, literal scalars will not right-trim each line for extra whitespace, allowing you to define Markdown-style new lines by ending a line with two spaces.

Thanks
------

[](#thanks)

A special thank you to [Thomas Weinert](https://github.com/ThomasWeinert) for doing the leg work of getting dipper into the composer, travis, and phpunit arenas.

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity27

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 98.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 ~102 days

Total

4

Last Release

3782d ago

### Community

Maintainers

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

---

Top Contributors

[![fredleblanc](https://avatars.githubusercontent.com/u/649331?v=4)](https://github.com/fredleblanc "fredleblanc (75 commits)")[![ThomasWeinert](https://avatars.githubusercontent.com/u/236825?v=4)](https://github.com/ThomasWeinert "ThomasWeinert (1 commits)")

---

Tags

parseryaml

### Embed Badge

![Health badge](/badges/secondparty-dipper/health.svg)

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

###  Alternatives

[nikic/php-parser

A PHP parser written in PHP

17.4k902.6M1.8k](/packages/nikic-php-parser)[doctrine/lexer

PHP Doctrine Lexer parser library that can be used in Top-Down, Recursive Descent Parsers.

11.2k910.8M117](/packages/doctrine-lexer)[erusev/parsedown

Parser for Markdown.

15.0k151.8M724](/packages/erusev-parsedown)[league/commonmark

Highly-extensible PHP Markdown parser which fully supports the CommonMark spec and GitHub-Flavored Markdown (GFM)

2.9k404.0M694](/packages/league-commonmark)[masterminds/html5

An HTML5 parser and serializer.

1.8k242.8M226](/packages/masterminds-html5)[sabberworm/php-css-parser

Parser for CSS Files written in PHP

1.8k191.2M63](/packages/sabberworm-php-css-parser)

PHPackages © 2026

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