PHP code example of drmvc / router

1. Go to this page and download the library: Download drmvc/router library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

drmvc / router example snippets



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);