PHPackages                             webuni/front-matter - 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. [Templating &amp; Views](/categories/templating)
4. /
5. webuni/front-matter

ActiveLibrary[Templating &amp; Views](/categories/templating)

webuni/front-matter
===================

Front matter parser and dumper for PHP

2.1.2(2mo ago)41264.9k↓21.6%1010MITPHPPHP ^8.1CI failing

Since Aug 11Pushed 2mo ago2 watchersCompare

[ Source](https://github.com/webuni/front-matter)[ Packagist](https://packagist.org/packages/webuni/front-matter)[ Docs](https://github.com/webuni/front-matter)[ RSS](/packages/webuni-front-matter/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (6)Dependencies (18)Versions (13)Used By (10)

Front Matter
============

[](#front-matter)

[![Packagist](https://camo.githubusercontent.com/a10b515722177d5596fa31440947a2231225859a639044f3dde594f7d958cab5/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f776562756e692f66726f6e742d6d61747465722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/webuni/front-matter)[![Quality Gate Status](https://camo.githubusercontent.com/01cbb4f356d1b209bbc344831e3fe751de504f156f2cc209b5eeae6239644aa1/68747470733a2f2f736f6e6172636c6f75642e696f2f6170692f70726f6a6563745f6261646765732f6d6561737572653f70726f6a6563743d776562756e695f66726f6e742d6d6174746572266d65747269633d616c6572745f737461747573)](https://sonarcloud.io/summary/new_code?id=webuni_front-matter)[![Coverage](https://camo.githubusercontent.com/3b567101438702dbec231ef59d89af019868b78bc800775ea1a0e033dffe89ef/68747470733a2f2f736f6e6172636c6f75642e696f2f6170692f70726f6a6563745f6261646765732f6d6561737572653f70726f6a6563743d776562756e695f66726f6e742d6d6174746572266d65747269633d636f766572616765)](https://sonarcloud.io/summary/new_code?id=webuni_front-matter)

The most universal Front matter (yaml, json, neon, toml) parser and dumper for PHP. Front matter allows page-specific variables to be included at the top of a page.

Features
--------

[](#features)

This library can parse all form of front matter:

YAML (Neon)TOMLJsonTwigPug```
---
foo: bar
---

# Section

Text
```

```
+++
foo = bar
+++

# Section

Text
```

```
{
  "foo": "bar"
}

# Section

Text
```

```
{#---
foo: bar
---#}

Section

{{ foo }}
```

```
--
  foo: bar

h1 Section

p= foo
```

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

[](#installation)

This library can be installed via Composer:

```
composer require webuni/front-matter

```

Usage
-----

[](#usage)

### Automatic front matter detection and parsing

[](#automatic-front-matter-detection-and-parsing)

The following code will automatically detect the above front matter types:

```
