PHP code example of remysd / simple-router

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

    

remysd / simple-router example snippets




use RemySd\SimpleRouter\Router;

$router = new Router();

$router->setBasePath('/simple-router');

$router->addRoute('/articles', 'article', 'all', 'article_all');
$router->addRoute('/articles/{id}', 'article', 'show', 'article_single');

$properties = $router->match($_SERVER['REQUEST_URI']);

$url = $router->generate('single_article', ['id' => 3]);