diff --git a/usage/mapping-routes.html b/usage/mapping-routes.html index 1080dd3..741b755 100644 --- a/usage/mapping-routes.html +++ b/usage/mapping-routes.html @@ -16,18 +16,19 @@ layout: default
The map()
method accepts the following parameters.
$method
(string)
+ $method
(string)
This is a pipe-delimited string of the accepted HTTP requests methods.
Example: GET|POST|PATCH|PUT|DELETE
$route
(string)
+ $route
(string)
This is the route pattern to match against. This can be a plain string, one of the predefined regex filters or a custom regex. Custom regexes must start with @
.
Examples:
Route | @@ -51,22 +52,22 @@ layout: default
---|
$target
(mixed) As AltoRouter leaves handling routes up to you, this can be anything.
+ $target
(mixed)
+ As AltoRouter leaves handling routes up to you, this can be anything.
Example using a function callback:
function() { ... }
-
+
Example using a controller#action string:
UserController#showDetails
$name
(string, optional)If you want to use reversed routing, specify a name parameter so you can later generate URL's using this route.
+
+ $name
(string, optional)
+ If you want to use reversed routing, specify a name parameter so you can later generate URL's using this route.
Example:
- user_details
+ user_details
You can use the following limits on your named parameters. AltoRouter will create the correct regexes for you.
-* // Match all request URIs
-[i] // Match an integer
-[i:id] // Match an integer as 'id'
-[a:action] // Match alphanumeric characters as 'action'
-[h:key] // Match hexadecimal characters as 'key'
-[:action] // Match anything up to the next / or end of the URI as 'action'
-[create|edit:action] // Match either 'create' or 'edit' as 'action'
-[*] // Catch all (lazy, stops at the next trailing slash)
-[*:trailing] // Catch all as 'trailing' (lazy)
-[**:trailing] // Catch all (possessive - will match the rest of the URI)
-.[:format]? // Match an optional parameter 'format' - a / or . before the block is also optional
-
The character before the colon (the 'match type') is a shortcut for one of the following regular expressions
-'i' => '[0-9]++'
-'a' => '[0-9A-Za-z]++'
-'h' => '[0-9A-Fa-f]++'
-'*' => '.+?'
-'**' => '.++'
-'' => '[^/\.]++'
-
You can register your own match types using the addMatchTypes()
method.
$router->addMatchTypes(array('cId' => '[a-zA-Z]{2}[0-9](?:_[0-9]++)?'));
-
Once your routes are all mapped you can start matching requests and continue processing the request.