drmvc / router
Simple router based on PSR-7 HTTP Message recommendation
3.0.4
2018-04-10 10:44 UTC
Requires
- php: ^7.0
- psr/http-message: ^1.0
Requires (Dev)
- phpunit/phpunit: ~6.0
- zendframework/zend-diactoros: ^1.7
README
DrMVC\Router
Simple router based on PSR-7 HTTP Message recommendation.
composer require drmvc/router
How to use
More examples you can find here.
<?php require_once __DIR__ . '/../vendor/autoload.php'; use Zend\Diactoros\ServerRequestFactory as ServerRequest; use Zend\Diactoros\Response as ServerResponse; use DrMVC\Router; // PSR Request and Response $request = ServerRequest::fromGlobals(); $response = new ServerResponse(); // Router object $router = new Router($request, $response); // Set routes $router ->get('/aaa/<action>/<action2>', DrMVC\Controllers\Index::class) ->get('/bbb/zzz/ccc', 'App\Controllers\Index:default') ->get( '/action/zzz', function() { echo "action\n"; } ); $route = $router->getRoute(); print_r($route);
About PHP Unit Tests
First need to install all dev dependencies via composer update
, then
you can run tests by hands from source directory via ./vendor/bin/phpunit
command.