Simple router based on PSR-7 HTTP Message recommendation

3.0.4 2018-04-10 10:44 UTC

This package is auto-updated.

Last update: 2024-04-29 03:44:45 UTC


Latest Stable Version Build Status Total Downloads License PHP 7 ready Code Climate Scrutinizer CQ


Simple router based on PSR-7 HTTP Message recommendation.

composer require drmvc/router

How to use

More examples you can find here.

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
    ->get('/aaa/<action>/<action2>', DrMVC\Controllers\Index::class)
    ->get('/bbb/zzz/ccc', 'App\Controllers\Index:default')
        function() {
            echo "action\n";

$route = $router->getRoute();

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.