Hoa is a modular, extensible and
structured set of PHP libraries.
Moreover, Hoa aims at being a bridge between industrial and research worlds.
This library dispatches a task defined by some data on a callable, or with the
appropriated vocabulary, on a controller and an action. It is often used in
conjunction with the
library and the
The link between libraries and the application is represented by a kit which aggregates all important data, such as the dispatcher, the router, the view and data associated to the view.
$ composer require hoa/dispatcher '~1.0'
For more installation procedures, please read the Source page.
Before running the test suites, the development dependencies must be installed:
$ composer install
Then, to run all the test suites:
$ vendor/bin/hoa test:run
For more information, please read the contributor guide.
We propose a quick overview of the basic dispatcher represented by the class
Hoa\Dispatcher\Basic which is able to dispatch a task on three kinds of
- lambda function (as a controller, no action);
- function (as a controller, no action);
- class and method (respectively as a controller and an action).
We will focus on the last kind with this following example:
$router = new Hoa\Router\Http(); $router->get('w', '/(?<controller>[^/]+)/(?<action>\w+)\.html'); $dispatcher = new Hoa\Dispatcher\Basic(); $dispatcher->dispatch($router);
By default, the controller will be
Application\Controller\<Controller> and the
action will be
<Action>Action. Thus, for the request
/Foo/Bar.html, we will
It is possible to specify a different controller and action names if the request
is asynchronous. By default, only the action name is different with the value
With all kinds of callables, the basic dispatcher will distribute captured data
(?<name>…) PCRE syntax) on callable arguments
name matches the argument name. For example, with a rule such as
'/hello_(?<nick>\w+)', if the callable has an argument named
$nick, it will
receive the value
gordon for the request
The kit is reachable through the
$_this argument or
$this variable if the
controller is a class that extends
Hoa\Dispatcher\Kit. The kit propose four
elementary attributes, which are:
hack book of
contains detailed information about how to use this library and how it works.
To generate the documentation locally, execute the following commands:
$ composer require --dev hoa/devtools $ vendor/bin/hoa devtools:documentation --open
More documentation can be found on the project's website: hoa-project.net.
There are mainly two ways to get help:
Do you want to contribute? Thanks! A detailed contributor guide explains everything you need to know.
Hoa is under the New BSD License (BSD-3-Clause). Please, see
LICENSE for details.