PHP code example of hyn / frontmatter

1. Go to this page and download the library: Download hyn/frontmatter 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/ */

    

hyn / frontmatter example snippets


$parser = new \Hyn\Frontmatter\Parser(new \cebe\markdown\Markdown);

// Uses json per default, but set specifically:
$parser->setFrontmatter(\Hyn\Frontmatter\Frontmatters\JsonFrontmatter::class);
// Use toml:
$parser->setFrontmatter(\Hyn\Frontmatter\Frontmatters\TomlFrontmatter::class);
// Or use yaml:
$parser->setFrontmatter(\Hyn\Frontmatter\Frontmatters\YamlFrontmatter::class);

// And parse the markdown file:
$contents = $parser->parse(file_get_contents('the-file.md'));
// Get meta
$meta = $parser->getMeta();