Action parameter usage

What is the best practice for using an action parameter. for instance, If I have an action called Index which has the parameter $name should I use that $name parameter directly without calling \Yii::$app->request->get(‘name’)? I’ve seen people using it directly without even doing some validation with conditional structure(if isset for example), so I am confused.

If you use


you need to call that action passing all parameters (except for that with an initialization).

If you get parameters inside the code, you can pass different parameters based on type of use that you want from that action.

The first approach is more readable and structured, the second is more flexible.

Thanks for the clear answer