PHaiku is an abstract class. It has to be extended to be used. By default it's extended by the Haiku class, but you can extend it by any other class.

External libraries

PHaiku uses Pimple as dependency injection container. And Slim framework as a basic framework.

Obviously dependencies are managed by Pimple. You can add your own services to the container in the ./config/services.php file.


Since the version 0.7 PHaiku uses composer to manage dependencies and autoloading.


All the configuration is in the ./config/config.php file. The upper part of the configuration file are Slim configurations

PHaiku specific configuration attributes are:

  • benchmark - if set to true, appends page generation and memory consumption to the bottom of the page
  • cache - enables caching. Caching is recommended in production mode.
  • cache.adapter - one of the available cache adapters. Possible values are:
    • Apc - use if you have Apc or Apcu php extensions installed on your system
    • File - file cache. This should work on any system, but it's slightly less performant.
    • MemCache - use if you have memcached available and appropriate php extension.
    • Memory - a volatile but fast memory caching.
    • Mongo - use MongoDB for caching.
    • MySQL - use mySQL database for caching. Not recommended.
    • Redis - use Redis for caching.
    • NotCache - dummy adapter that circumvents caching. Intended for tests and debugging.
    Apc, Apcu, File and MemCache have been tested. Other methods should work too. Please provide feedback if you test them.
  • cache.time - the time to live of cached emtities
  • cache.flush.url - the url you will use to clear the cache if needed
  • - the name of the class that extends PHaiku
  • - relative path to the folder containing content data
  • default.ext - default extention of the data files
  • multilingual - set to true if the site is multilingual
  • default.language - the two letter code of the default language
  • languages - array of available language codes. Only needed for multilingual sites.
  • widgets - defines an array of widgets to be loaded by default. A widget is defined by it's name, the defining handler and an array of arguments that will be passed to the handler.


Since version 0.8, routes are configured in a separate file config/routes.php

  • routes - array containing the routes. Each route should contain
    • name - the name of the route
    • route - relative url of the route with parameters
    • method - one of the http methods
    • handler - the class method that will handle the request
    You can use as many routes as you want. The higher routes take precedence over the lower ones when more matches are possible.
  • route.conditions - conditions that each route parameter must comply with for the route to be valid.


  • static $basedir - defines the absolute path to the working directory.
  • static $version - defines the PHaiku versoion.
  • protected $app - contains an instance of \Slim\Slim.
  • protected $lang - contains the current language as set by the url or default
  • public $data - contains an array of objects of class \Phaiku\Data data passed to the view


Please see the source code.


That's all there is for now. For more information consult the source code.


Feel free to comment or ask questions! Thanks!

comments powered by Disqus

Execution time: 0.0240s Memory usage: 0.679528MB