yaml-front-matter

A to the point yaml front matter parser

  • 所有者: spatie/yaml-front-matter
  • 平台:
  • 许可证: MIT License
  • 分类:
  • 主题:
  • 喜欢:
    0
      比较:

Github星跟踪图

yaml-front-matter

Latest Version on Packagist
Software License
Build Status
Quality Score
Total Downloads

A to the point front matter parser. Front matter is metadata written in yaml, located at the top of a file wrapped in ---'s.

---
title: Example
---

Lorem ipsum.
$object = YamlFrontMatter::parse(file_get_contents(__DIR__.'/example.md'));

$object->matter('title'); // => 'Example';
$object->body(); // => 'Lorem ipsum.'

// Or retrieve front matter with a property call...

$object->title; // => 'Example';

Spatie is a webdesign agency based in Antwerp, Belgium. You'll find an overview of all our open source projects on our website.

Install

You can install the yaml-front-matter via composer:

$ composer require spatie/yaml-front-matter

Usage

Consider the example.md file from above. First you'll need to parse the contents:

$object = YamlFrontMatter::parse(file_get_contents('example.md'));

The parser will return a YamlFrontMatterObject, which can be queried for front matter or it's body.

$object->matter(); // => ['title' => 'Example']
$object->matter('title'); // => 'Example'
$object->body(); // => 'Lorem ipsum.'
$object->title; // => 'Example'

Protip: The matter function also accepts dot notation for nested fields, e.g. matter('meta.keywords').

Changelog

Please see CHANGELOG for more information what has changed recently.

Testing

$ vendor/bin/phpunit

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email freek@spatie.be instead of using the issue tracker.

Postcardware

You're free to use this package, but if it makes it to your production environment we highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using.

Our address is: Spatie, Samberstraat 69D, 2060 Antwerp, Belgium.

We publish all received postcards on our company website.

Credits

Support us

Spatie is a webdesign agency based in Antwerp, Belgium. You'll find an overview of all our open source projects on our website.

Does your business depend on our contributions? Reach out and support us on Patreon.
All pledges will be dedicated to allocating workforce on maintenance and new awesome stuff.

License

The MIT License (MIT). Please see License File for more information.

概览

名称与所有者spatie/yaml-front-matter
主编程语言PHP
编程语言PHP (语言数: 1)
平台
许可证MIT License
发布数14
最新版本名称2.0.8 (发布于 )
第一版名称1.0.0 (发布于 )
创建于2016-01-13 21:26:46
推送于2023-12-04 10:03:30
最后一次提交
星数321
关注者数10
派生数28
提交数110
已启用问题?
问题数0
打开的问题数0
拉请求数21
打开的拉请求数0
关闭的拉请求数5
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?
去到顶部