This package is abandoned and no longer maintained. No replacement package was suggested.

Library for defining content in a similar way as Jekyll.

v1.0.3 2013-11-21 13:25 UTC

This package is auto-updated.

Last update: 2018-11-30 14:53:20 UTC


Library for defining content in a similar way as Jekyll. Created to provide a high-performance alternative to database-driven websites with a small amount of content.

Latest Stable Version Total Downloads Latest Unstable Version Build Status Scrutinizer Quality Score Code Coverage SensioLabsInsight

What is it?

A current trend is to develop your own personal site with help of static site generators like Jekyll and Middleman. Because these projects provide a solution for the question why you should need a full-blown CMS for a site with a small amount of content. But these projects don't fit in a site where you need some dynamics in the backend like search, a Twitter feed or comments. All of this functionality is moved to the frontend with help of some awesome Javascript libraries. On the other hand, what if you still need some dynamics in the backend? That's where Fabricius fills in the gap!

Fabricius aims to provide a solution for sites with a small amount of content, but still be dynamic. Using the same principles as Jekyll for defining your static content, you can query these anywhere in your PHP application.


  • Define your content just like Jekyll.
  • Write in the language you prefer, even if it's HTML, Markdown or Textile.
  • Query your static content at blazing speeds with the excellent YaLinqo library.
  • Serve your content from Google Drive, Dropbox, Github or locally
  • Store content in your application with Memcache, files or array
  • Integrates easily with Symfony or Silex


The recommended way to install Fabricius is through composer.

    "require": {
        "fabricius/fabricius": "~1.0"

Who is this Fabricius?

Johann Albert Fabricius (November 11, 1668 – April 30, 1736) was a German classical scholar and bibliographer. Fabricius was born at Leipzig, son of Werner Fabricius, director of music in the church of St. Paul at Leipzig, who was the author of several works, the most important being Deliciae Harmonicae (1656). The son received his early education from his father, who on his deathbed recommended him to the care of the theologian Valentin Alberti.

Read more about this guy at Wikipedia


Here is an example of loading all content items under /content formatted in Markdown:


require __DIR__.'/../vendor/autoload.php';

use Doctrine\Common\Annotations\AnnotationRegistry;
use Doctrine\Common\Cache\ArrayCache;
use Fabricius\Events;
use Fabricius\Formatter\Formatter;
use Fabricius\Formatter\Handler\MarkdownPhpHandler;
use Fabricius\Formatter\Handler\TextileHandler;
use Fabricius\LibraryBuilder;
use Fabricius\Loader\FileLoader;
use Fabricius\Validator\Validator;
use Symfony\Component\Finder\Finder;
use Symfony\Component\Validator\ConstraintValidatorFactory;
use Symfony\Component\Validator\DefaultTranslator;


$library = LibraryBuilder::create()

$constraintValidatorFactory = new ConstraintValidatorFactory();
$translator = new DefaultTranslator();

$validator = new Validator($library, $constraintValidatorFactory, $translator);

$formatter = new Formatter($library);

if (class_exists('dflydev\markdown\MarkdownExtraParser')) {
    $markdownHandler = new MarkdownPhpHandler();

if (class_exists('Netcarver\Textile\Parser')) {
    $textileHandler = new TextileHandler();

$library->getEventDispatcher()->addListener(Events::CONTENT_PARSED, array($validator, 'onContentItemParsed'), -100);
$library->getEventDispatcher()->addListener(Events::CONTENT_PARSED, array($formatter, 'onContentItemParsed'));

$finder = new Finder();
$provider = new FileLoader($finder, __DIR__.'/content');

$cache = new ArrayCache();

$library->registerRepository('Namespace\Of\Article\Class', $provider, $cache);

$content = $library->getRepository('Namespace\Of\Article\Class')->query();

foreach ($content->toArray() as $contentItem) {
  // Prints 'Example'.
  print $contentItem->getTitle();

A basic content file looks like the following:

title: Example
categories: [test, dummy]
tags: [test, dummy, phpunit, mock]
published: true

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus ut tincidunt arcu. Curabitur
ac risus diam. Curabitur urna nibh, rutrum id tincidunt vel, consequat quis magna. Curabitur sit
amet sapien a arcu tempor varius. Integer vitae lorem non tortor aliquam faucibus. Nunc ut
vulputate purus. In bibendum quam at risus tincidunt sed auctor lectus scelerisque. Donec rhoncus
tortor ornare libero placerat mollis. Fusce quis purus justo. Sed sagittis diam aliquam eros
aliquet aliquam.
<!-- more -->

Nunc fringilla, lorem a vestibulum porta, metus dui congue elit, nec blandit urna libero sit amet
dolor. In hac habitasse platea dictumst. Quisque ut sem euismod urna congue placerat. Quisque at
nisl nisl. Sed lobortis viverra condimentum. Etiam condimentum nisl et sem tincidunt a commodo
purus malesuada. Cras eu mauris velit. Aliquam rutrum, tortor quis egestas faucibus, velit risus
eleifend eros, at consectetur erat lorem sed est. Proin tristique tempus ante vitae elementum.
Nullam at risus ut est gravida facilisis eget vitae odio. Curabitur metus libero, pulvinar in gravida
non, iaculis quis odio. Aliquam sed bibendum orci. Mauris consectetur tristique mi, non dapibus
elit molestie iaculis.

More examples can be found in the examples directory.

Querying content

You can query the defined content items through the excellent YaLinqo library. Here is an example for finding the first ten published content items tagged with php, ordered by date:

// see the above example on how to bootstrap the Fabricius library instance.

$content = $library->getRepository('Article')->query()
    ->where(function ($contentItem) {
        return in_array('php', $article->getTags());
    ->where(function ($contentItem) {
        return $contentItem->getPublished();
    ->orderByDescending(function ($contentItem) {
        return $contentItem->getCreated();

For more examples about querying through YaLinqo, check out its examples.


To run the test suite, you need PHPUnit.

$ phpunit