Get a named parameter value from request Yii's named parameters are available in the template. For example, for the following route configuration:

'post/&lt;post_id:\d+&gt;' =&gt; ['template' =&gt; 'post-entry'],


The value of post_id in my template for the request post/3 will be 3.

But how can I access it from PHP, for example from the Craft::app -&gt; getRequest() ? 

Note: I don't mean queryString parameters. QueryString parameters can be accessed using getParam('paramName').
It is passed as a parameter to your function

public function actionView($post_id){
    Craft::dd($post_id);
}


Note: your parameter must have the same name like defined in your route. You can't access it with public function actionView($postId)