Download the PHP package daylerees/kurenai without Composer
On this page you can find all versions of the php package daylerees/kurenai. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package kurenai
Kurenai
Kurenai is a document with metadata parsing library for PHP. It supports a variety of different document content and metadata parsers.
Installation
Kurenai is available on Packagist for Composer.
composer require daylerees/kurenai
Usage
Kurenai documents look like this:
A metadata section, and a content section seperated by three equals ===
signs or more.
Here's an example using JSON for metadata, and Markdown for content.
Formats for metadata and content are interchangable using classes called parsers. First, let's create our parser instance.
In the above example, we're using a JSON metadata parser, and a Markdown content parser. We can now parse a document.
Our documents can have any filename or extension. You can also pass the parse()
function the content of a document directly.
The document instance has a few useful methods.
This will fetch the raw document content. Before Kurenai parsed it.
This will fetch the metadata, parsed into an array.
This will get the content of the document, rendered using the provided content parser.
The get()
method uses dot-notation to return a metadata value. For example, the above example would be equivalent to fetching $metadata['foo']['bar']
.
If the subject can't be found, null
will be returned. You can supply a default value as a second parameter to the method.
Metadata Parsers
Format | Install Package | Class |
---|---|---|
JSON | N/A | Kurenai\Parsers\Metdata\JsonParser |
YAML | symfony/yaml |
Kurenai\Parsers\Metdata\YamlParser |
INI | N/A | Kurenai\Parsers\Metdata\IniParser |
Content Parsers
Format | Install Package | Class |
---|---|---|
Plaintext (no parsing) | N/A | Kurenai\Parsers\Content\PlainTextParser |
CommonMark | league/commonmark |
Kurenai\Parsers\Content\CommonMarkParser |
Markdown | michelf/php-markdown |
Kurenai\Parsers\Content\MarkdownParser |
Markdown Extra | michelf/php-markdown |
Kurenai\Parsers\Content\MarkdownExtraParser |
Parsedown (Github Markdown) | erusev/parsedown |
Kurenai\Parsers\Content\ParsedownParser |
Textile | netcarver/textile |
Kurenai\Parsers\Content\TextileParser |
Enjoy using Kurenai!