icanboogie / bind-http
Binds icanboogie/http to ICanBoogie
Installs: 2 145
Dependents: 2
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Requires
- php: >=7.2
- icanboogie/http: ^4.0
- icanboogie/icanboogie: ^5.0
Requires (Dev)
- phpunit/phpunit: ^8.5
README
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 thehttp_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.