1. Go to this page and download the library: Download ergebnis/front-matter library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
ergebnis / front-matter example snippets
declare(strict_types=1);
use Ergebnis\FrontMatter;
$parser = new FrontMatter\YamlParser();
$unparsedContentWithoutFrontMatter = FrontMatter\Content::fromString('Hello, how are you today?');
$parser->hasFrontMatter($unparsedContentWithoutFrontMatter); // false
$unparsedContentWithFrontMatter = FrontMatter\Content::fromString(<<<TXT
---
page:
title: "Hello"
description: "Good to see you, how can I help you?"
---
TXT);
$parser->hasFrontMatter($unparsedContentWithFrontMatter); // true
declare(strict_types=1);
use Ergebnis\FrontMatter;
$parser = new FrontMatter\YamlParser();
$unparsedContentWithoutFrontMatter = FrontMatter\Content::fromString('Hello, how are you today?');
/** @var FrontMatter\Parsed $parsedWithoutFrontMatter */
$parsedWithoutFrontMatter = $parser->parse($unparsedContentWithoutFrontMatter);
$unparsedContentWithFrontMatter = FrontMatter\Content::fromString(<<<TXT
---
page:
title: "Hello"
description: "Good to see you, how can I help you?"
---
TXT);
/** @var FrontMatter\Parsed $parsedWithFrontMatter */
$parsedWithFrontMatter = $parser->parse($unparsedContentWithoutFrontMatter);
var_dump($parsedWithFrontMatter->frontMatter()->data()->has('page.title')); // true
var_dump($parsedWithFrontMatter->frontMatter()->data()->get('page.title')); // "Hello"
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.