Yii framework: Controller/Action url & parameters Yii framework: Controller/Action url & parameters php php

Yii framework: Controller/Action url & parameters


You're going to need to put in rule patterns in the urlManager component:

Yii Framework Documentation: url

Your config should look something like this:

array(    ......    'components'=>array(        ......        'urlManager'=>array(            'urlFormat'=>'path',            'rules'=>array(                'api/users/<id>'=>'api/users',            ),        ),    ),);

You can then get the value by:

$id = Yii::app()->getRequest()->getQuery('id');


Try This......

$id = Yii::app()->request->getParam('id');


in addition to @shiki's answer you can also do this

array(    ......    'components'=>array(        ......        'urlManager'=>array(            'urlFormat'=>'path',            'rules'=>array(                'api/users/<id>'=>'api/users',            ),        ),    ),);

and in action

public function actionUsers($id=null)  // argument variable should same as in urlmanager    {     echo $id;    }