PHPackages                             carc1n0gen/phrontmatter - 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. carc1n0gen/phrontmatter

ActiveLibrary

carc1n0gen/phrontmatter
=======================

v1.0.0(10y ago)025MITPHP

Since May 9Pushed 3y ago1 watchersCompare

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

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

PhrontMatter
============

[](#phrontmatter)

A PHP library for parsing documents with frontmatter.

By default, documents are parsed as markdown with YAML front matter. The front matter begins and ends with "---" like [Jekyll](http://jekyllrb.com/docs/frontmatter/)

Install
-------

[](#install)

$ `composer require carc1n0gen/phrontmatter`

Example
-------

[](#example)

```
use \Carc1n0gen\PhrontMatter\Parser;

// Create a Parser instance with default options.
$parser = new Parser();

$document = $parser->parse(file_get_contents('path/to/markdown/file'));

// If the front matter contaned:
// ---
// author:
//   firstName: John
//   lastName: Smith
// ---
print_r($document->getFrontMatter());

// Returns:
// Array
// (
//     [author] => Array
//         (
//             [firstName] => John
//             [lastName] => Smith
//         )
//
// )
```

The parsed document content can be accessed with `$document->getContent()`.

You can provide `false` as the second parameter to `$parser->parse` if you wish to leave the document content as is with no parsing. For example, if the document content is in HTML format and does not need parsing.

Different Front Matter Formats
------------------------------

[](#different-front-matter-formats)

PhrontMatter allows you to write your front matter in any format you like, and comes with two built in adapters for YAML, and JSON. So you could also write the front matter in JSON.

### JSON Front Matter

[](#json-front-matter)

```
use \Carc1n0gen\PhrontMatter\Parser;
use \Carc1n0gen\PhrontMatter\Adapter\JSONAdapter;

// Create in instance of the JSON parser adapter.
$adapter = new JSONAdapter();

// Create a Parser instance with a custom front matter adapter.
$parser = new Parser($adapter);

$document = $parser->parse(file_get_contents('path/to/markdown/file'));

// If the front matter contaned:
// ---
// {
//     "author": {
//         "firstName": "John",
//         "lastName": "Smith"
//     }
// }
// ---
print_r($document->getFrontMatter());

// Returns:
// stdClass Object
// (
//     [author] => stdClass Object
//         (
//             [firstName] => John
//             [lastName] => Smith
//         )
//
// )
```

### Custom Parser Adapters

[](#custom-parser-adapters)

The Parser class cunstructor signature is:

```
public function __construct(ParserInterface $frontMatterParser = null,
                            ParserInterface $contentParser = null,
                            $startSep = '---',
                            $endSep = '---')

```

You can supply the constructor with your own front matter parsing adapter in the case you want to use another format besides YAML or JSON, You could supply the consturctor with your own content parsing adapter in the case you want to write the document content in a format other than markdown, and you can supply the constructor with custom begin/end separators for the front matter section of your document.

When writing a custom parser adapter, one only needs to meet the `\Carc1n0gen\PhrontMatter\ParserInterface` interface.

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity63

Established project with proven stability

 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

Unknown

Total

1

Last Release

3652d ago

### Community

Maintainers

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

---

Top Contributors

[![carc1n0gen](https://avatars.githubusercontent.com/u/8248986?v=4)](https://github.com/carc1n0gen "carc1n0gen (20 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/carc1n0gen-phrontmatter/health.svg)

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

###  Alternatives

[kimai/kimai

Kimai - Time Tracking

4.6k7.4k1](/packages/kimai-kimai)[afragen/git-updater

A plugin to automatically update GitHub, Bitbucket, GitLab, or Gitea hosted plugins, themes, and language packs.

3.3k1.6k](/packages/afragen-git-updater)

PHPackages © 2026

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