PHP code example of faustvik / router

1. Go to this page and download the library: Download faustvik/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/ */

    

faustvik / router example snippets


$collections = new RoutesCollection();

$fd = RouteAnonymousFunc::create('/anonym', static function (){
    echo "Anonymous Func";
}, ['POST']);

$collections->set(
    Route::create('/', TestController::class, 'actionIndex',[], ['POST'], '/aliasIndex'),
    $fd,
);

$config = new Config();
$config->setRunner(new Runner());

$router = new Router();
$router->setConfig($config);
$router->setCollection($collections);
$router->run();

Route::create('/', TestController::class, 'actionIndex',[], ['POST'], '/aliasIndex'),

RouteAnonymousFunc::create('/anonym', static function (){
    echo "Anonymous Func";
}, ['POST']);

$config = new Config();
$config->setRunner(new RunnerSmp());

$router = new Router();
$router->setConfig($config);