Added known routes example to readme

This commit is contained in:
SteamPixel 2021-03-22 09:11:59 +01:00
parent 03b7de9fcc
commit 91aec2d0bc
2 changed files with 13 additions and 1 deletions

View File

@ -76,6 +76,18 @@ You can find an example in index.php. However, this is deactivated, as it only w
Route::add('/arrow/([a-z-0-9-]*)', fn($foo) => 'This is a working arrow function example. Parameter: '.$foo );
```
## Return all known routes
This is useful, for example, to automatically generate test routes or help pages.
```php
$routes = Route::getAll();
foreach($routes as $route) {
echo $route['expression'].' ('.$route['method'].')';
}
```
On top of that you could use a library like https://github.com/hoaproject/Regex to generate working example links for the different expressions.
## Enable case sensitive routes, trailing slashes and multi match mode
The second, third and fourth parameters of `Route::run('/', false, false, false);` are set to false by default.
Using this parameters you can switch on and off several options:

View File

@ -209,7 +209,7 @@ Route::add('/known-routes', function() {
$routes = Route::getAll();
echo '<ul>';
foreach($routes as $route) {
echo '<li>'.$route['expression'].'</li>';
echo '<li>'.$route['expression'].' ('.$route['method'].')</li>';
}
echo '</ul>';
});