Download the PHP package zloynick/joole-components-routing without Composer
On this page you can find all versions of the php package zloynick/joole-components-routing. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Please rate this library. Is it a good library?
Informations about the package joole-components-routing
Joole Component: Router
This component allows you to configure routes for your project.
Getting started
- Install this dependency via composer:
composer install zloynick/joole-components-routing
Configuration
Add to components this in your joole.php configuration file:
'components' => [
...,
[
'name' => 'router',
'class' => \joole\components\routing\RoutingComponent::class,
// Component options
'options' => [
// Routes path
'routes' => __DIR__.'/routes/',
],
],
...,
],
Using
Create your routes in the folder that you specified in the component configuration:
----------- routes.php -----------
...
// Closure using.
BaseRouter::register('route.test', '/my/action/:name/:and_id', function(string $name, int $and_id):\joole\framework\http\Response{
return response();
}
);
// Controller using.
BaseRouter::register('route.test', '/my/action/:name/:and_id', ['\app\controllers\DefaultController::class', 'index']);
// OR
BaseRouter::register('route.test', '/my/action/:name/:and_id', '\app\controllers\DefaultController::class@index');
...
Validation of requests
Use Validator to create a request parameter validation class.
Example:
...
BaseRouter::register('route.test', '/my/action/:name/:and_id', function(string $name, int $and_id):\joole\framework\http\Response{
return response();
}
)->withValidators(YourValidator1::class, ..., new Validator2());
...
All versions of joole-components-routing with dependencies
PHP Build Version
Package Version
The package zloynick/joole-components-routing contains the following files
Loading the files please wait ....