Route Pattern Syntax and Placeholders
masterFastRoute uses a specific syntax for route patterns:
- Basic Placeholder:
{foo}matches[^/]+. - Custom Regex Placeholder:
{bar:[0-9]+}allows you to specify a custom regular expression. Note: Custom patterns cannot use capturing groups like(en|de). Use non-capturing groups(?:en|de)instead. - Optional Parts: Parts enclosed in
[...]are optional. Optional parts must be at the end of the route pattern.
Examples:
/user/{id:\d+}matches/user/42but not/user/xyz./user/{name:.+}matches/user/foo/bar./user/{id:\d+}[/{name}]matches both/user/123and/user/123/john./user[/{id:\d+}[/{name}]]supports nested optional parts.