PHP code example of spatie / yaml-front-matter
1. Go to this page and download the library: Download spatie/yaml-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/ */
spatie / yaml-front-matter example snippets
use Spatie\YamlFrontMatter\YamlFrontMatter;
$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';
use Spatie\YamlFrontMatter\YamlFrontMatter;
$object = YamlFrontMatter::parse(file_get_contents('example.md'));
$object->matter(); // => ['title' => 'Example']
$object->matter('title'); // => 'Example'
$object->body(); // => 'Lorem ipsum.'
$object->title; // => 'Example'