Basic Usage

The application is basically a configuration and an execution code.

Index File

The application object is configured, created, bootstrapped and dispatched in the index file.

<?php // index.php

use WebinoAppLib\Application\CoreConfig;
use WebinoAppLib\Feature as AppFeature;
use WebinoConfigLib\Feature as ConfigFeature;

require 'vendor/autoload.php';

/**
 * Configure and create an application.
 * Use configurators instead of writing PHP arrays.
 * Create your custom configurators.
 */

$config = Webino::config([
    new ConfigFeature\Log,
    new ConfigFeature\FirePhpLog,
    new AppFeature\FilesystemCache,

    (new MyCustomFeature)
        ->setAnything(),
]);

$appCore = Webino::application($config);

/**
 * Application $appCore is not fully configured.
 * Only core services and listeners are available.
 * Configuration is write enabled.
 */

$app = $appCore->bootstrap();

/**
 * Application $app is configured and ready for a dispatch.
 * All services and listeners are available.
 * Configuration is read-only.
 */

$app->dispatch();

Routing

A route is a map from a URL path to an event. When a route gets hit it will trigger an event on which you can bind custom code.

Adding routes

Adding routes via configuration.

use WebinoConfigLib\Feature\Route;

Webino::config([
    (new Route('myRoute'))->setLiteral('/my/route/path'),
]);

Adding routes runtime.

/** @var \WebinoConfigLib\Feature\Route $route */
$route = $app->route('myRoute')->setLiteral('/my/route/path');

Generating URLs

Generating URLs to application routes.

/** @var WebinoAppLib\Router\UrlInterface $url */
$url = $app->url('myRoute');

Binding to routes

Handling a route match.

use WebinoAppLib\Event\RouteEvent;

$app->bindRoute('myRoute', function (RouteEvent $event) {
    // do something...
});

Requests

TODO…

Responses

TODO…