yii2에서 500 오류를 사용자 정의하는 방법
1 ErrorHandler를 생성하고 이 yiibaseErrorHandler 추상 클래스를 상속한 다음 이 상위 클래스
<?php namespace common\component\exception; /** * User: szliugx@gmail.com * Date: 2016/9/20 * Time: 14:24 */ use yii; use yii\base\ErrorHandler as BaseErrorHandler; use common\component\earlywarning\EarlyWarning; class ErrorHandler extends BaseErrorHandler { public $errorView = '@app/views/errorHandler/error.php'; public function renderException($exception) { if(Yii::$app->request->getIsAjax()){ exit( json_encode( array('code' =>$exception->getCode(),'msg' =>$exception->getMessage()) )); }else{ //将500的代码,发送监控预警 if(!empty($exception->getCode()) && $exception->getCode() ==8){ $params = []; $params['projectName'] = "oct-youban"; $params['level'] = 5; $params['title'] = "500:".$exception->getMessage(); $params['value'] = $exception->getCode(); $params['message'] = $exception->getFile().":".$exception->getLine(); $params['bizcode'] = 8; $params['subcode'] = 8001; EarlyWarning::WarninApi($params); } echo Yii::$app->getView()->renderFile($this->errorView,['exception' => $exception,],$this); } } }
권장 튜토리얼: yii Framework
2에서 뷰 파일을 생성합니다. errorHandler/error .php
<?php /** * User: szliugx@gmail.com * Date: 2016/9/20 * Time: 15:23 */ ?> <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no"> <meta name="apple-mobile-web-app-capable" content="yes"> <meta name="apple-mobile-web-app-status-bar-style" content="black"> <meta name="format-detection" content="telephone=no"> <meta http-equiv="Expires" content="-1"> <meta http-equiv="Cache-Control" content="no-cache"> <meta http-equiv="Pragma" content="no-cache"> <title><?php if(!empty($exception->getCode())&&($exception->getCode() == 8)){echo "出错啦";}else{ echo $exception->getMessage();}?></title> <link href="/css/error.css" rel="stylesheet" 0="frontend\assets\AppAsset"> </head> <body> <div> <div class="status-icon icon-desk"></div> <div> <p><?php if(!empty($exception->getCode())&&($exception->getCode() == 8)){echo "出错啦";}else{ echo $exception->getMessage();}?></p> </div> </div> </body> </html>
3. 애플리케이션 구성 파일을 수정합니다: @app/config/main.php
'errorHandler' => [ //'errorAction' => 'site/error', 'class' => 'common\component\exception\ErrorHandler', ],
효과는 다음과 같습니다:
500 오류 페이지:
404 오류 페이지:
더보기 프로그래밍 관련 내용은 PHP 중국어 홈페이지의 프로그래밍 입문 칼럼을 주목해주세요!
위 내용은 yii2에서 500 오류를 사용자 정의하는 방법의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

핫 AI 도구

Undresser.AI Undress
사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover
사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool
무료로 이미지를 벗다

Clothoff.io
AI 옷 제거제

AI Hentai Generator
AI Hentai를 무료로 생성하십시오.

인기 기사

뜨거운 도구

메모장++7.3.1
사용하기 쉬운 무료 코드 편집기

SublimeText3 중국어 버전
중국어 버전, 사용하기 매우 쉽습니다.

스튜디오 13.0.1 보내기
강력한 PHP 통합 개발 환경

드림위버 CS6
시각적 웹 개발 도구

SublimeText3 Mac 버전
신 수준의 코드 편집 소프트웨어(SublimeText3)

뜨거운 주제











yii2에서 jquery를 제거하는 방법: 1. AppAsset.php 파일을 편집하고 $dependents 변수의 "yii\web\YiiAsset" 값을 주석 처리합니다. 2. main.php 파일을 편집하고 구성을 "'yii"로 추가합니다. "comComponents" \web\JqueryAsset' => ['js' => [],'sourcePath' => null,]" 필드 아래에서 jquery 스크립트를 제거합니다.

이 기사에서는 yii2 프레임워크를 소개하고 몇 가지 CTF 연습을 공유하며 이를 사용하여 yii2 프레임워크를 학습하는 것이 모든 사람에게 도움이 되기를 바랍니다.

500 내부 서버 오류는 HTTP 500 내부 서버 오류를 의미합니다. 이는 서버가 예상치 못한 상황에 직면하여 요청을 이행할 수 없지만 오류 발생 시 특정 오류나 오류의 근본 원인을 설명할 수 없음을 의미합니다. 방문한 웹사이트에 오류가 표시됩니다.

1. Composer가 포함된 yii2-redis 마스터 브랜치의 Windows 버전을 다운로드해야 합니다. 2. 압축을 풀고 Vendor/yiisoft에 복사합니다. 3. 'yiisoft/yii2-redis'=>array('name'=>'yiisoft 추가 yiisoft /yii2-redis','version'=>'2.0 아래의 Extensions.php로.

한 전문가에 따르면 2011년 작품은 2012년 런던 올림픽을 기념하기 위해 제작된 것이라고 합니다.

이더리움 가격은 2,250달러 수준을 넘어 회복세를 시작했습니다. ETH는 2,280달러 저항 구역을 통과하여 플러스 구역으로 진입할 수 있었지만 비트코인에 비해 모멘텀은 약했습니다.

비트코인은 $57,500 저항선을 넘어 상당한 상승세를 시작했으며 이제 잠재적으로 $60,000 선에 도달할 가능성이 있는 조짐을 보여주고 있습니다.

2012년 런던 올림픽을 기념하여 주조된 2011년 동전은 "수영" 디자인으로 알려져 있으며 수영선수의 이미지를 담고 있습니다.
