Documentation Index
Fetch the complete documentation index at: https://mintlify.com/MonishAMPT/fastroute-code/llms.txt
Use this file to discover all available pages before exploring further.
Introduction
Dynamic parameters allow you to capture values from the URL and pass them to your handler functions. FastRoute supports parameter placeholders with optional regex validation.Basic Parameter Syntax
Parameters are defined using curly braces{} with optional regex patterns:
Parameter Patterns
The syntax for parameters is{name:pattern} where:
nameis the parameter namepatternis an optional regex pattern\d+matches one or more digits
The colon (
:) separates the parameter name from the regex pattern. If no pattern is provided, the parameter matches any value.Accessing Parameters in Handlers
Parameters are passed to your handler function as an array:Complete Example
Here’s a complete example showing routes with parameters:routes/api.php
Regex Patterns
Common regex patterns for route parameters:Handler Implementation
The dispatcher passes matched parameters to your handler:index.php
Use Cases
Resource IDs
Capture numeric IDs for database lookups
Slugs
Use human-readable URLs with slug parameters
Multiple Params
Combine multiple parameters in a single route
Validation
Use regex patterns to validate input format
Next Steps
HTTP Methods
Learn about different HTTP method support
REST API
Build complete RESTful APIs