Hello addItEasy 0.1.0!

Hello addItEasy 0.1.0!

I was looking for a way to show how our libraries like Adrenaline, Pathfinder and Disco work in a "real world" application. I came up with the idea to build just another simple flat-file CMS. AddItEasy might be the first flat-file CMS based on a PSR-7 implementation which adds a nice touch: We can easily create a static file export from the content. That means that you do not need to upload addItEasy to your server, you can simply export the files and e.g. let GitHub host the static HTML pages.

To install addItEasy use Composer:

composer.phar require bitexpert/additeasy

To initialize a new project use the built-in cli tool:

./vendor/bin/addItEasy init

This creates a bunch of directories and folders:


Find the project specific configuration in config/config.inc.php, the default version looks like this:

$EASY_CONF = [];

// addITeasy configuration
$EASY_CONF["app"] = [];
$EASY_CONF["app"]["cachedir"] = __DIR__ . "/../cache";
$EASY_CONF["app"]["assetdir"] = __DIR__ . "/../assets";
$EASY_CONF["app"]["logfile"] = $EASY_CONF["app"]["cachedir"] . "/easy.log";
$EASY_CONF["app"]["datadir"] = __DIR__ . "/../content";
$EASY_CONF["app"]["templatedir"] = __DIR__ . "/../template/";
$EASY_CONF["app"]["exportdir"] = __DIR__ . "/../export";
$EASY_CONF["app"]["defaultpage"] = "";

// Site configuration (these vars get passed to the twig template)
$EASY_CONF["site"][] = "";
$EASY_CONF["site"]["title"] = "addITeasy Demosite";
$EASY_CONF["site"]["baseurl"] = "http://localhost:8080/";

You are able to configure the cache directory, the asset directory, the data directory containing the content files and the template directory. Variables defined in $EASY_CONF["site"] will be passed as is to Twig which is used as templating engine. Access those variables like this: site.title or site.baseurl.

Templates need the placed in the template folder, a template could look like this:

<!DOCTYPE html>
<html lang="en">
    <title>{{ site.title }}</title>
    <base href="{{ site.baseurl }}" />

<!-- Content block -->
{% block content %}
{% endblock %}


Content files are also twig templates and need to be placed in the content folder. The content files need to extend a template and provide all the needed blocks a template requires.

{% extends "default.twig" %}

{% block content %}
    Hello World!
{% endblock content %}

Every page of your site is represented by a subfolder in the content directory. The folder names build the URL structure for your site, nested subfolders are allowed. Each folder needs to be prefixed with a number which is used to indicate the sorting order. Each folder needs to contain one twig template file containing the content to display. The content folder could look like this:


In case you want to run addItEasy locally the following command needs to be executed in the project directory:

php -S -t .

Open a web browser and point it to http://localhost:8080 so see addItEasy in action. In case you want to export the content as static HTML files run the following command:

./vendor/bin/addItEasy export

This will export all pages into the directory defined in $EASY_CONF["app"]["exportdir"] as well as copying all the assets.

Eintrag von Stephan Hochdörfer am 19.07.2016

Tags: PHP, CMS, PSR-7

Diese Webseite verwendet Cookies, um die Bedienfreundlichkeit zu erhöhen. Mit der Nutzung unserer Webseite wird das Einverständnis erklärt, dass wir Cookies verwenden. Weitere Informationen.