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:
@ -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
|
||||||
|
Reference in New Issue
Block a user