Yii2 中配置方法汇总


1.默认框架接收的是x-www-format-unencode格式的数据,如果想要接收text/json格式的数据,会为空,这个时候需要在配置文件中添加对应的配置项

commonents:

'request' => [  
    'enableCookieValidation' => false,  
    'parsers' => [  
        'application/json' => 'yii\web\JsonParser',  
        'text/json' => 'yii\web\JsonParser',  
    ]  
],