为什么重装后YII2里面的POST是空的?

Why is the empty POST in YII2 after reinstallation?

我们为移动应用开发了自己的 api,它基于 post 请求工作,但是在新服务器上重新安装项目后,Yii :: $ app-> request- > post()总是returns一个空值。同时,Yii::$app->request->getRawBody()包含一个值,但我不想重写所有api.

告诉我可能是什么问题以及挖掘方法?提前致谢。

通过移动应用程序发送或post通过 RestClient PHPStorm 发送。 Returns总是空虚。

public function behaviors()
{
    return [
        'access' => [
            'class' => AccessControl::class,
            'only' => ['logout', 'signup'],
            'rules' => [
                [
                    'actions' => ['login'],
                    'allow' => true,
                    'roles' => ['?'],
                ],
                [
                    'actions' => ['login'],
                    'allow' => true,
                    'roles' => ['@'],
                ],
            ],
        ],
        'verbs' => [
            'class' => VerbFilter::class,
            'actions' => [
                'login' => ['post', 'get'],
                'token' => ['post', 'get'],
                'logout' => ['post', 'get'],
            ],
        ],
    ];
}

public function beforeAction($action) {
    $this->enableCsrfValidation = false;
    return parent::beforeAction($action);
}

public function actionLogin()
{
    return Yii::$app->request->post("username");
}

可能是您的请求是通过 get() 方法

$app->request->get();

重新安装项目后,问题自行解决。感谢大家。