Hubert

Simple example

This is an easy example in a php file. At first you have to insert the composer autoloader.

require 'vendor/autoload.php'

Now you define the configuration. In this example the configuration contains only one route for the home page that returns "Hello World":

$config = array(
    "routes" => array(
        "home" => array(
            "route" => "/", 
            "target" => function($request, $response, $args){
                echo "Hello World";
            }
        )
    )
);

Now Hubert can be initialised using this configuration:

hubert($config);

At last you fire off the core components run() command:

hubert()->core()->run();

This is the full index.php:

<?php

require 'vendor/autoload.php';

$config = array(
    "routes" => array(
        "home" => array(
            "route" => "/", 
            "target" => function($request, $response, $args){
                echo "Hello World";
            }
        )
    )
);

hubert($config);
hubert()->core()->run();

Server configuration

The server must be configured to redirect all request to index.php. Using Apache you create a new .htaccess file with the following content:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . index.php [L]