本文實例講述了Laravel5.1自定義500錯誤頁面的方法。分享給大家供大家參考,具體如下:
Laravel 5.1中500錯誤是程序錯誤,程序錯誤一定是系統(tǒng)自帶的500錯誤,可以通過以下步驟簡單實現(xiàn)自定義500錯誤頁面。
編輯PHP文件app/Exceptions/Handler.php內(nèi)容如下:
public function render($request, Exception $e){ if ($e instanceof ModelNotFoundException) { $e = new NotFoundHttpException($e->getMessage(), $e); } if($e instanceof /Symfony/Component/Debug/Exception/FatalErrorException && !config('app.debug')) { return response()->view('errors.default', [], 500); } return parent::render($request, $e);}然后編輯自定義錯誤頁面對應(yīng)視圖文件errors.default.blade.php。
希望本文所述對大家基于Laravel框架的PHP程序設(shè)計有所幫助。
新聞熱點
疑難解答
圖片精選