Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prepare for v2.0-RC1 #271

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ $r->addRoute('POST', '/test', 'handler');
$r->addRoute(['GET', 'POST'], '/test', 'handler');
```

By default the `$routePattern` uses a syntax where `{foo}` specifies a placeholder with name `foo`
By default, the `$routePattern` uses a syntax where `{foo}` specifies a placeholder with name `foo`
and matching the regex `[^/]+`. To adjust the pattern the placeholder matches, you can specify
a custom pattern by writing `{bar:[0-9]+}`. Some examples:

Expand All @@ -102,7 +102,7 @@ Custom patterns for route placeholders cannot use capturing groups. For example
is not a valid placeholder, because `()` is a capturing group. Instead you can use either
`{lang:en|de}` or `{lang:(?:en|de)}`.

Furthermore parts of the route enclosed in `[...]` are considered optional, so that `/foo[bar]`
Furthermore, parts of the route enclosed in `[...]` are considered optional, so that `/foo[bar]`
will match both `/foo` and `/foobar`. Optional parts are only supported in a trailing position,
not in the middle of a route.

Expand Down Expand Up @@ -142,7 +142,7 @@ $r->addRoute('POST', '/post-route', 'post_handler');

#### Route Groups

Additionally, you can specify routes inside of a group. All routes defined inside a group will have a common prefix.
Additionally, you can specify routes inside a group. All routes defined inside a group will have a common prefix.

For example, defining your routes as:

Expand Down Expand Up @@ -178,13 +178,15 @@ $dispatcher = FastRoute\cachedDispatcher(function(FastRoute\RouteCollector $r) {
$r->addRoute('GET', '/user/{id:[0-9]+}', 'handler1');
$r->addRoute('GET', '/user/{name}', 'handler2');
}, [
'cacheFile' => __DIR__ . '/route.cache', /* required */
'cacheKey' => __DIR__ . '/route.cache', /* required */
// 'cacheFile' => __DIR__ . '/route.cache', /* will still work for v1 compatibility */
'cacheDisabled' => IS_DEBUG_ENABLED, /* optional, enabled by default */
'cacheDriver' => FastRoute\Cache\FileCache::class, /* optional, class name or instance of the cache driver - defaults to file cache */
]);
```

The second parameter to the function is an options array, which can be used to specify the cache
file location, among other things.
key (e.g. file location when using files for caching), caching driver, among other things.

### Dispatching a URI

Expand Down Expand Up @@ -237,7 +239,7 @@ interface Dispatcher {
```

The route parser takes a route pattern string and converts it into an array of route infos, where
each route info is again an array of it's parts. The structure is best understood using an example:
each route info is again an array of its parts. The structure is best understood using an example:

/* The route /user/{id:\d+}[/{name}] converts to the following array: */
[
Expand Down
6 changes: 2 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
}
],
"require": {
"php": ">=8.1.0"
"php": ">=8.1.0",
"psr/simple-cache": "^2.0 || ^3.0"
},
"require-dev": {
"lcobucci/coding-standard": "^11.0",
Expand All @@ -25,9 +26,6 @@
"phpstan/phpstan-strict-rules": "^1.5",
"phpunit/phpunit": "^10.3"
},
"suggest": {
"ext-apcu": "To be able to use APCu cache driver"
},
"autoload": {
"psr-4": {
"FastRoute\\": "src/"
Expand Down
Loading
Loading