1
0
mirror of https://github.com/dannyvankooten/AltoRouter.git synced 2025-07-09 19:06:29 +02:00

add example for url generation to readme

This commit is contained in:
Danny van Kooten
2018-08-19 11:51:01 +02:00
parent 281c5631db
commit ca2d425bc6

View File

@ -9,11 +9,14 @@ $router->map( 'GET', '/', function() {
require __DIR__ . '/views/home.php'; require __DIR__ . '/views/home.php';
}); });
// map users details page // dynamic named route
$router->map( 'GET|POST', '/users/[i:id]/', function( $id ) { $router->map( 'GET|POST', '/users/[i:id]/', function( $id ) {
$user = ..... $user = .....
require __DIR__ . '/views/user/details.php'; require __DIR__ . '/views/user/details.php';
}); }, 'user-details' );
// echo URL to user-details page for ID 5
echo $router->generate( 'user-details', array( 'id' => 5 ) ); // Output: "/users/5"
``` ```
## Features ## Features