How variable names are matched in UriTemplate::expand()
2.0Variable names in the template must match the keys in the provided variables array exactly.
- Dot Separators: Names can use dots (e.g.,
user.id), but cannot start/end with a dot or contain empty parts. - Numeric Names: If a variable name consists entirely of digits (e.g.,
{0}), PHP's integer coercion applies.['0' => 'x']and[0 => 'x']are treated as the same key. However, non-canonical numeric strings like{01}must be provided as exact string keys ('01'). - Percent-encoding: Percent-encoded triplets in variable names are treated as part of the name and are not decoded for lookup.
UriTemplate::expand('/users/{user.id}', [
'user.id' => 123,
]);