mirror of
https://github.com/dannyvankooten/AltoRouter.git
synced 2025-07-29 20:50:25 +02:00
use short array notation in readme too
This commit is contained in:
@@ -5,18 +5,18 @@ AltoRouter is a small but powerful routing class, heavily inspired by [klein.php
|
|||||||
$router = new AltoRouter();
|
$router = new AltoRouter();
|
||||||
|
|
||||||
// map homepage
|
// map homepage
|
||||||
$router->map( 'GET', '/', function() {
|
$router->map('GET', '/', function() {
|
||||||
require __DIR__ . '/views/home.php';
|
require __DIR__ . '/views/home.php';
|
||||||
});
|
});
|
||||||
|
|
||||||
// dynamic named route
|
// 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' );
|
}, 'user-details');
|
||||||
|
|
||||||
// echo URL to user-details page for ID 5
|
// echo URL to user-details page for ID 5
|
||||||
echo $router->generate( 'user-details', array( 'id' => 5 ) ); // Output: "/users/5"
|
echo $router->generate('user-details', ['id' => 5]); // Output: "/users/5"
|
||||||
```
|
```
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
Reference in New Issue
Block a user