Need help understanding how query parameters work in url creation, routing, and hyperlinking


As I’ve been learning the yii2 framework, I’ve figured out that the index in the second parameter of a hyperlink function, such as “<?= Html::a(‘Profile’, [‘user/view’, ‘id’ => $id], [‘class’ => ‘profile-link’]) ?” shows an array, however, I only understand with certainty how the first index of the second parameter operates; it’s a string which tells the link which controller and then which action function to call.

My question is related to the second parameter; the second parameter shows an " ‘id’ “, where is this variable stored? Is it under a model? Is it in a base class within the yii framework? I’ve also seen code where the ‘id’ can be replaced with an array of some sort with id as an index, if for example I see instead of ‘id’ => $id” I saw something like “FindForm[id]=$id” , where would FindForm[id] be located within the yii framework? Under a model ? a controller?

Once the id is passed to that controller and action designation, how does the controller know which type of view to render? I’ve seen code where the query parameter is sent to the action, but I dont see the id actually being used, and it’s confusing me.

Can someone please explain to me how the query parameters work in yii? I know its a basic question but I can’t find any information about it anywhere.

Thanks for you help

Have a look here

Or perhaps start further down the article