drmvc/router

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: 2022-04-28 23:05:43 UTC


README

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

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.

Links