Accessing named parameter in custom route from within a controller I have a custom module in which I am setting a front end route that routes through to a controller. Like so:

 Event::on(
    UrlManager::class,
    UrlManager::EVENT_REGISTER_SITE_URL_RULES,
    function (RegisterUrlRulesEvent $event) {
        $event-&gt;rules['my-account/orders/&lt;order&gt;/pause'] = 'custom-module-name/order/pause-order';
    }
);


This works fine but how can I access that &lt;order&gt; named parameter within my controller? Is the only way to use craft::$app-&gt;request-&gt;getSegment(3);?
Hat tip to Andrew Welch for the answer.

With the route my-account/orders/&lt;order&gt;/pause it's possible to simply add the parameter to my controller method definition and it gets populated from the named parameter in the route.

  public function actionPauseOrder($order = null)
    {

       // do stuff
    }


The value of the named parameter order can then be accessed in the function as one would expect.

Super simple!