Adding parameters to Rest api

Hi, I want to know how can I add parameters to a function through the GET method in a rest api

This is my urlManager:




'urlManager' => [

            'enablePrettyUrl' => true,

            'enableStrictParsing' => true,

            'showScriptName' => false,

            'rules' => [

                ['class' => 'yii\rest\UrlRule',

                    'controller' => 'v1/institution',

                    'pluralize'=>false,

                    'extraPatterns' => [

                        'GET names' => 'names', 

                    ],

                ],

            ],

        ],



I’m calling it this way: api/v1/institution/names

and this is my function:




 public function actionNames(){


            //code return all names


    }



It works ok… but what if I want to pass some params to the function ?




 public function actionNames($param1,$param2){


            //code


    }



How can I do this ?

Thanks!

I figured out how to do it…

I had to add "Tokens" inside "urlManager" but, you can not use "extraPatterns" and "Tokens" under the same rule so I had to separate them:




'urlManager' => [

            'enablePrettyUrl' => true,

            'enableStrictParsing' => true,

            'showScriptName' => false,

            'rules' => [

                ['class' => 'yii\rest\UrlRule',

                    'controller' => 'v1/institution',

                    'pluralize'=>false,

                    'extraPatterns' => [

                        'name' => 'name',

                    ],

                ],

                ['class' => 'yii\rest\UrlRule',

                    'controller' => 'v1/institution',

                    'tokens' => [

                        '{id}' => '<id:\\w+>',

                    ]

                ],

            ],

        ],



Now I’m able to add params like api/v1/institution/name?id=1

I’m not sure if this is the right way to do it, but it works :)