lumen 开启调试模式,关闭debug输出,只保留数据验证提示

我们在使用lumen验证数据输出时,往往会有debug详细错误输出,在正式模式中我们是不需要的,哪我们怎么关闭呢,很简单

修改文件:vendor\dingo\api\src\Exception\Handler.php

带debug模式的输出
 //  return new Response(array("code"=>1,"data"=>$response["message"],"debug"=>$response["debug"]), $this->getStatusCode($exception), $this->getHeaders($exception));
只有错误码和提示的输出
  return new Response(array("code"=>1,"data"=>$this->unicodeDecode($response["message"])), $this->getStatusCode($exception), $this->getHeaders($exception));
}
/*将unicodel转为中文*/
private function unicodeDecode($unicode_str){
$json = '{"str":"'.$unicode_str.'"}';
$arr = json_decode($json,true);
if(empty($arr)) return '';
return $arr['str'];
}

 

posted @ 2019-08-11 23:25  fogwu  阅读(1326)  评论(0编辑  收藏  举报