2017 © Pedro Peláez
 

library thin

Flat file content management package for PHP.

image

petersuhm/thin

Flat file content management package for PHP.

  • Tuesday, March 25, 2014
  • by petersuhm
  • Repository
  • 1 Watchers
  • 0 Stars
  • 10 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 2 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Thin - Flat file content management

Thin is a package for flat file content management. By default, it supports files in Markdown and Markdown Extra format., (*1)

Installation

Install Thin from Packagist:, (*2)

"petersuhm/thin": "dev-master"

Usage

You can make your own implementations, depending on your type of content and which parser you want to use (it's Markdown by default). By default, Thin comes with two parsers, one for Markdown and one for Markdown Extra, and one model to handle blog posts., (*3)

$postLoader = new \Thin\PostLoader;

$postLoader->config(array(
    'document_path' = '../posts',
    'document_ext' = '.md'
));

// Returns a DocumentCollection
$posts = $postLoader->all();

// You can limit the number of documents
$posts->limit(5);

// You can also order documents by metadata
$posts->orderBy('date', 'desc');
$posts->orderBy('date', 'desc')->limit(3);

foreach ($posts as $post)
{
    $post->getMetadata('title');
    $post->getContent();
    $post->getHtmlContent();

    // Metadata can be accessed dynamically as well:
    $post->title;

    // Optionally give an instance of ParserInterface as a parameter
    $post->getHtmlContent(new \Thin\Parsers\MarkdownExtraParser);

}

// The PostLoader uses a slug as identifier
$post = $postLoader->find('some-slug');

The PostLoader expects files to follow the following convention:, (*4)

{
    "some_metadata": "In JSON format",
    "...": "..."
}

The content of the document.

If your files have a different format, you can write your own loader., (*5)

The Versions

25/03 2014

dev-master

9999999-dev

Flat file content management package for PHP.

  Sources   Download

MIT

The Requires

 

The Development Requires