我开启了restfunll API 数据返回和验证都没有问题了,
config里也配置了
return [
// ...
'components' => [
'response' => [
'class' => 'yii\web\Response',
'on beforeSend' => function ($event) {
$response = $event->sender;
if ($response->data !== null && Yii::$app->request->get('suppress_response_code')) {
$response->data = [
'success' => $response->isSuccessful,
'data' => $response->data,
];
$response->statusCode = 200;
}
},
],
],
];
但是就是访问的路径不存在的时候,返回的还是html
因为配置里
'errorHandler' => [
'errorAction' => 'site/error',
],
所以会去找site/error
我在 SiteController.php中写了
public function actionError(){
return ['status'=>'fail','msg'=>'load 错误'];
if($error=Yii::app()->errorHandler->error)
{
return $error;
}
}
提示找不到error.php view
目前金钱 只有 5
???????????