Yii2 中配置方法汇总

 

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

commonents:

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

 2. 设置框架的时区

config > main.php

return [
    "timeZone"=> 'Asia/Shanghai',
    'components'=[
        ...
    ]
]

 

posted @ 2022-01-17 15:35  X-Wolf  阅读(127)  评论(0编辑  收藏  举报