PHP code example of pfinal / routing

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

    

pfinal / routing example snippets




use Symfony\Component\HttpFoundation\Request;
use PFinal\Routing\Router;

$router = new Router();

$router->get('/', function () {
    return 'index';
});

$router->any('/blog/:id', function ($id) {
    return $id;
});

$router->post('/blog/:name/update', function ($name) {
    return $name;
});

$request = Request::createFromGlobals();

$response = $router->dispatch($request);
$response->send();