我們在使用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'];
}
