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. [Utility &amp; Helpers](/categories/utility)
4. /
5. carc1n0gen/phrontmatter

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

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

v1.0.0(10y ago)035MITPHP

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 today

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

28

—

LowBetter than 52% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

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

3707d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/8248986?v=4)[Carson Evans](/maintainers/carc1n0gen)[@carc1n0gen](https://github.com/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.8k9.0k1](/packages/kimai-kimai)[friendsoftypo3/content-blocks

TYPO3 CMS Content Blocks - Content Types API | Define reusable components via YAML

103519.9k53](/packages/friendsoftypo3-content-blocks)[rcsofttech/audit-trail-bundle

Enterprise-grade, high-performance Symfony audit trail bundle. Automatically track Doctrine entity changes with split-phase architecture, multiple transports (HTTP, Queue, Doctrine), and sensitive data masking.

1189.8k](/packages/rcsofttech-audit-trail-bundle)[blackfire/player

A powerful web crawler and web scraper with Blackfire support

49617.1k](/packages/blackfire-player)[altis/local-server

Local Server module for Altis

18221.6k3](/packages/altis-local-server)

PHPackages © 2026

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