icanboogie/bind-http

Binds icanboogie/http to ICanBoogie

5.0 2021-05-31 22:28 UTC

This package is auto-updated.

Last update: 2022-09-13 07:54:59 UTC


README

Release Build Status Code Quality Code Coverage Packagist

The icanboogie/bind-http package binds icanboogie/http to ICanBoogie.

Defining domain dispatchers using config fragments

Domain dispatchers may be defined using configuration fragments. One actually define dispatcher constructors as a class name or a callable, that would return a dispatcher. Constructor class should extend the AbstractDispatcherConstructor.

The following example demonstrates how some domain dispatchers may be defined:

<?php

// config/http.php

use ICanBoogie\Binding\HTTP\DispatcherConfig as Config;

return [

    'dispatchers' => [

        'pages' => [

            Config::CONSTRUCTOR => \Icybee\Modules\Pages\PageDispatcher::class,
            Config::WEIGHT => Config::WEIGHT_BOTTOM

        ],

        'routing' => \ICanBoogie\Routing\RouteDispatcher::class,

        'operation' => [

            Config::CONSTRUCTOR => \ICanBoogie\Operation\OperationDispatcher::class,
            Config::WEIGHT => Config::WEIGHT_BEFORE_PREFIX . 'routing'

        ]

    ]

];

The dispatchers configuration may be obtained through the application:

<?php

// …

$config = $app->configs['http_dispatchers'];

Prototype methods

The following prototype methods are defined, the ApplicationBindings trait may be used for type hinting:

  • ICanBoogie\Application::get_initial_request: Returns the initial request.
  • ICanBoogie\Application::get_request: Returns the current request.
  • ICanBoogie\Application::get_dispatcher: Returns the request dispatcher.

The following example demonstrates how this getters may be used:

<?php

namespace ICanBoogie;

require 'vendor/autoload.php';

$app = boot();

$initial_request = $app->initial_request;
$request = $app->request;
$dispatcher = $app->dispatcher;

Event hooks

The following event hooks are attached:

  • ICanBoogie\Application::configure: Used to define an instance of ProvideDispatcher as dispatcher provider. This provider uses the http_dispatchers configuration to create the request dispatcher.

Requirements

The package requires PHP 7.2 or later.

Installation

composer require icanboogie/bind-http

Documentation

The package is documented as part of the ICanBoogie framework documentation. You can generate the documentation for the package and its dependencies with the make doc command. The documentation is generated in the build/docs directory. ApiGen is required. The directory can later be cleaned with the make clean command.

Testing

Run make test-container to create and log into the test container, then run make test to run the test suite. Alternatively, run make test-coverage to run the test suite with test coverage. Open build/coverage/index.html to see the breakdown of the code coverage.

License

icanboogie/bind-http is released under the New BSD License.