3

How to write this line of code from Yii to Yii 2.0:

Yii::app()->getRequest()->getRestParams() ?

delux
  • 1,694
  • 10
  • 33
  • 64

5 Answers5

2

I believe it is

Yii::$app->request->restParams

or

Yii::$app->getRequest()->getRestParams()

and you may find the following issue interesting

https://github.com/yiisoft/yii/issues/259

nazim
  • 1,439
  • 2
  • 16
  • 26
2

In my opinion, the equivalent of

Yii::app()->getRequest()->getRestParams()

in Yii 2 is

Yii::$app->request->getBodyParams()

moreover, if you would like to know the method of the request (POST, PATCH, DELETE etc.), you can use Yii::$app->request->getMethod()

More information about the Request class instance you can find here.

bds
  • 266
  • 2
  • 6
2

you can use it this way

Yii::$app->request->getBodyParams()

there are more similar methods, please check here https://www.yiiframework.com/doc/api/2.0/yii-web-request

see the guide article as well https://www.yiiframework.com/doc/guide/2.0/en/runtime-requests

Azraar Azward
  • 1,586
  • 2
  • 12
  • 16
1

According to Yii1 it is changed like the below.

Yii::$app->request->bodyParams;

You can see here for other details also.

http://www.yiiframework.com/doc-2.0/guide-runtime-requests.html

1

Try the following

 Yii::$app->getRequest()->getQueryParam()

check this link

Mohan Kumar
  • 169
  • 1
  • 9