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'];
}
 
        

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM