Path Parameters
Dynamic routing with automatic type-cast parameter injection.
{year}/{month}/{slug} placeholders in the route pattern are captured and passed to your handler automatically.
Two access styles — call
$c->getPathParam() manually, or let Via inject matching parameters directly into your callback's function signature.Reflection-based injection matches parameter names to route placeholders. Type-hint
int and Via casts the value for you — no manual parsing required.Two Ways to Use Path Parameters
Manual Access
$name = $c->getPathParam('name');
Auto-Injection
function(Context $c, string $name) {…}
Try It Out
👁 Views
path_params.html.twig
Landing page with links to both blog (manual) and article (auto-injection) routes.
path_params_detail.html.twig
Detail page showing extracted year, month, and slug from the URL.