{"id":1059,"date":"2025-01-18T12:38:14","date_gmt":"2025-01-18T04:38:14","guid":{"rendered":"https:\/\/www.laixuexila.com\/?p=1059"},"modified":"2025-01-18T12:38:14","modified_gmt":"2025-01-18T04:38:14","slug":"laravel-%e9%94%99%e8%af%af%e5%a4%84%e7%90%86%e8%af%a6%e8%a7%a3%ef%bc%9a%e4%bb%8e%e5%bc%82%e5%b8%b8%e6%8d%95%e8%8e%b7%e5%88%b0%e8%87%aa%e5%ae%9a%e4%b9%89%e9%94%99%e8%af%af%e9%a1%b5%e9%9d%a2","status":"publish","type":"post","link":"https:\/\/www.laixuexila.com\/index.php\/2025\/01\/18\/laravel-%e9%94%99%e8%af%af%e5%a4%84%e7%90%86%e8%af%a6%e8%a7%a3%ef%bc%9a%e4%bb%8e%e5%bc%82%e5%b8%b8%e6%8d%95%e8%8e%b7%e5%88%b0%e8%87%aa%e5%ae%9a%e4%b9%89%e9%94%99%e8%af%af%e9%a1%b5%e9%9d%a2\/","title":{"rendered":"Laravel \u9519\u8bef\u5904\u7406\u8be6\u89e3\uff1a\u4ece\u5f02\u5e38\u6355\u83b7\u5230\u81ea\u5b9a\u4e49\u9519\u8bef\u9875\u9762"},"content":{"rendered":"\n<h3 class=\"wp-block-heading\"><strong>Laravel &#8211; \u9519\u8bef\u5904\u7406\uff1a\u5168\u9762\u89e3\u6790\u4e0e\u6700\u4f73\u5b9e\u8df5<\/strong><\/h3>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>\u5728 Laravel \u4e2d\uff0c\u9519\u8bef\u5904\u7406\u662f\u5e94\u7528\u7a0b\u5e8f\u5f00\u53d1\u7684\u4e00\u4e2a\u81f3\u5173\u91cd\u8981\u7684\u90e8\u5206\u3002Laravel \u63d0\u4f9b\u4e86\u5f3a\u5927\u7684\u9519\u8bef\u548c\u5f02\u5e38\u5904\u7406\u673a\u5236\uff0c\u80fd\u591f\u6355\u83b7\u5e94\u7528\u4e2d\u7684\u5404\u79cd\u9519\u8bef\u5e76\u7ed9\u51fa\u53cb\u597d\u7684\u54cd\u5e94\uff0c\u5e2e\u52a9\u5f00\u53d1\u8005\u5feb\u901f\u5b9a\u4f4d\u548c\u89e3\u51b3\u95ee\u9898\u3002<\/p>\n\n\n\n<p>\u672c\u6587\u5c06\u6df1\u5165\u4ecb\u7ecd Laravel \u4e2d\u7684\u9519\u8bef\u5904\u7406\u673a\u5236\uff0c\u5305\u62ec\u9519\u8bef\u6355\u83b7\u3001\u5f02\u5e38\u5904\u7406\u3001\u65e5\u5fd7\u8bb0\u5f55\u3001\u7528\u6237\u53cb\u597d\u7684\u9519\u8bef\u9875\u9762\u4ee5\u53ca\u5982\u4f55\u81ea\u5b9a\u4e49\u9519\u8bef\u5904\u7406\u3002<\/p>\n<\/blockquote>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>\u4e00\u3001Laravel \u9519\u8bef\u5904\u7406\u6982\u8ff0<\/strong><\/h3>\n\n\n\n<p>Laravel \u57fa\u4e8e <strong>Whoops<\/strong> \u9519\u8bef\u5904\u7406\u5305\u6765\u5904\u7406\u5f00\u53d1\u73af\u5883\u4e2d\u7684\u5f02\u5e38\uff0c\u5e76\u4f7f\u7528 <strong>Monolog<\/strong> \u4f5c\u4e3a\u751f\u4ea7\u73af\u5883\u4e2d\u7684\u65e5\u5fd7\u8bb0\u5f55\u7cfb\u7edf\u3002Laravel \u7684\u9519\u8bef\u5904\u7406\u5305\u62ec\u4ee5\u4e0b\u51e0\u4e2a\u90e8\u5206\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u5f02\u5e38\u5904\u7406\uff08Exception Handling\uff09<\/strong>\uff1a\u6355\u83b7\u5e76\u5904\u7406\u5e94\u7528\u4e2d\u7684\u5f02\u5e38\u3002<\/li>\n\n\n\n<li><strong>\u9519\u8bef\u9875\u9762<\/strong>\uff1a\u4e3a\u4e0d\u540c\u7c7b\u578b\u7684\u9519\u8bef\u63d0\u4f9b\u7528\u6237\u53cb\u597d\u7684\u754c\u9762\u3002<\/li>\n\n\n\n<li><strong>\u65e5\u5fd7\u8bb0\u5f55<\/strong>\uff1a\u8bb0\u5f55\u9519\u8bef\u4fe1\u606f\uff0c\u4ee5\u4fbf\u540e\u7eed\u5206\u6790\u548c\u6392\u67e5\u95ee\u9898\u3002<\/li>\n\n\n\n<li><strong>\u81ea\u5b9a\u4e49\u9519\u8bef\u5904\u7406<\/strong>\uff1a\u5141\u8bb8\u5f00\u53d1\u8005\u6839\u636e\u4e1a\u52a1\u9700\u6c42\u5b9a\u5236\u9519\u8bef\u5904\u7406\u6d41\u7a0b\u3002<\/li>\n<\/ol>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>\u4e8c\u3001Laravel \u4e2d\u7684\u5f02\u5e38\u5904\u7406<\/strong><\/h3>\n\n\n\n<h4 class=\"wp-block-heading\">2.1 <strong>\u5168\u5c40\u5f02\u5e38\u5904\u7406<\/strong><\/h4>\n\n\n\n<p>Laravel \u4f7f\u7528\u4e00\u4e2a\u540d\u4e3a <code>App\\Exceptions\\Handler<\/code> \u7684\u7c7b\u6765\u5904\u7406\u5e94\u7528\u4e2d\u7684\u5f02\u5e38\u3002\u8fd9\u4e2a\u7c7b\u4f4d\u4e8e <code>app\/Exceptions\/Handler.php<\/code> \u6587\u4ef6\u4e2d\uff0c\u8d1f\u8d23\u6355\u83b7\u6240\u6709\u672a\u5904\u7406\u7684\u5f02\u5e38\u5e76\u751f\u6210\u54cd\u5e94\u3002\u4f60\u53ef\u4ee5\u5728\u8fd9\u91cc\u5b9a\u5236\u5982\u4f55\u5904\u7406\u4e0d\u540c\u7c7b\u578b\u7684\u5f02\u5e38\u3002<\/p>\n\n\n\n<p><code>Handler<\/code> \u7c7b\u6709\u4e24\u4e2a\u4e3b\u8981\u65b9\u6cd5\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong><code>register()<\/code><\/strong>\uff1a\u7528\u4e8e\u6ce8\u518c\u5f02\u5e38\u7684\u5904\u7406\u65b9\u5f0f\u3002<\/li>\n\n\n\n<li><strong><code>report()<\/code><\/strong>\uff1a\u7528\u4e8e\u5c06\u5f02\u5e38\u62a5\u544a\u7ed9\u65e5\u5fd7\u7cfb\u7edf\u6216\u5176\u4ed6\u9519\u8bef\u8ddf\u8e2a\u7cfb\u7edf\uff08\u5982 Sentry\u3001Bugsnag \u7b49\uff09\u3002<\/li>\n\n\n\n<li><strong><code>render()<\/code><\/strong>\uff1a\u7528\u4e8e\u751f\u6210\u5f02\u5e38\u54cd\u5e94\uff0c\u901a\u5e38\u662f\u8fd4\u56de\u4e00\u4e2a\u9519\u8bef\u9875\u9762\u6216 JSON \u54cd\u5e94\u3002<\/li>\n<\/ul>\n\n\n\n<p>\u4ee5\u4e0b\u662f <code>Handler.php<\/code> \u4e2d\u7684\u793a\u4f8b\u4ee3\u7801\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>namespace App\\Exceptions;\n\nuse Exception;\nuse Illuminate\\Foundation\\Exceptions\\Handler as ExceptionHandler;\nuse Illuminate\\Support\\Facades\\Log;\nuse Symfony\\Component\\HttpKernel\\Exception\\NotFoundHttpException;\n\nclass Handler extends ExceptionHandler\n{\n    public function register()\n    {\n        \/\/ \u6ce8\u518c\u81ea\u5b9a\u4e49\u7684\u5f02\u5e38\u5904\u7406\u65b9\u5f0f\n        $this-&gt;reportable(function (NotFoundHttpException $e) {\n            \/\/ \u5904\u7406 404 \u9519\u8bef\n            Log::warning('Page not found: ' . $e-&gt;getMessage());\n        });\n    }\n\n    public function render($request, Exception $exception)\n    {\n        \/\/ \u9488\u5bf9\u7279\u5b9a\u5f02\u5e38\u8fd4\u56de\u81ea\u5b9a\u4e49\u7684\u9519\u8bef\u9875\u9762\n        if ($exception instanceof NotFoundHttpException) {\n            return response()-&gt;view('errors.404', &#91;], 404);\n        }\n\n        \/\/ \u9ed8\u8ba4\u9519\u8bef\u9875\u9762\n        return parent::render($request, $exception);\n    }\n}<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">2.2 <strong>\u5e38\u89c1\u7684\u5f02\u5e38\u7c7b<\/strong><\/h4>\n\n\n\n<p>Laravel \u63d0\u4f9b\u4e86\u591a\u79cd\u5e38\u89c1\u7684\u5f02\u5e38\u7c7b\uff0c\u7528\u4e8e\u5904\u7406\u4e0d\u540c\u7c7b\u578b\u7684\u9519\u8bef\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong><code>HttpException<\/code><\/strong>\uff1a\u5904\u7406 HTTP \u9519\u8bef\uff0c\u5982 404\u3001403 \u7b49\u3002<\/li>\n\n\n\n<li><strong><code>NotFoundHttpException<\/code><\/strong>\uff1a\u5904\u7406\u9875\u9762\u672a\u627e\u5230\u7684\u9519\u8bef\uff08\u901a\u5e38\u662f 404 \u9519\u8bef\uff09\u3002<\/li>\n\n\n\n<li><strong><code>AuthenticationException<\/code><\/strong>\uff1a\u5904\u7406\u8ba4\u8bc1\u5931\u8d25\u7684\u9519\u8bef\uff08\u5982\u672a\u767b\u5f55\uff09\u3002<\/li>\n\n\n\n<li><strong><code>AuthorizationException<\/code><\/strong>\uff1a\u5904\u7406\u6388\u6743\u5931\u8d25\u7684\u9519\u8bef\uff08\u5982\u6743\u9650\u4e0d\u8db3\uff09\u3002<\/li>\n\n\n\n<li><strong><code>ValidationException<\/code><\/strong>\uff1a\u5904\u7406\u8868\u5355\u9a8c\u8bc1\u9519\u8bef\u3002<\/li>\n\n\n\n<li><strong><code>QueryException<\/code><\/strong>\uff1a\u5904\u7406\u6570\u636e\u5e93\u67e5\u8be2\u9519\u8bef\u3002<\/li>\n<\/ul>\n\n\n\n<p>\u4f60\u53ef\u4ee5\u5728 <code>Handler<\/code> \u7c7b\u7684 <code>render()<\/code> \u65b9\u6cd5\u4e2d\u6355\u83b7\u8fd9\u4e9b\u5f02\u5e38\u5e76\u5b9a\u5236\u54cd\u5e94\u884c\u4e3a\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>\u4e09\u3001\u9519\u8bef\u9875\u9762\u7684\u5b9a\u5236<\/strong><\/h3>\n\n\n\n<p>Laravel \u63d0\u4f9b\u4e86\u9ed8\u8ba4\u7684\u9519\u8bef\u9875\u9762\uff0c\u4f46\u4f60\u53ef\u4ee5\u6839\u636e\u9700\u6c42\u81ea\u5b9a\u4e49\u8fd9\u4e9b\u9519\u8bef\u9875\u9762\uff0c\u4ee5\u4fbf\u4e3a\u7528\u6237\u63d0\u4f9b\u66f4\u53cb\u597d\u7684\u9519\u8bef\u63d0\u793a\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">3.1 <strong>404 \u9519\u8bef\u9875\u9762<\/strong><\/h4>\n\n\n\n<p>\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0cLaravel \u4f1a\u5728 <code>resources\/views\/errors\/404.blade.php<\/code> \u6587\u4ef6\u4e2d\u67e5\u627e\u81ea\u5b9a\u4e49\u7684 404 \u9519\u8bef\u9875\u9762\u3002\u4f60\u53ef\u4ee5\u521b\u5efa\u8be5\u6587\u4ef6\u5e76\u81ea\u5b9a\u4e49\u9875\u9762\u5185\u5bb9\u3002<\/p>\n\n\n\n<p>\u4f8b\u5982\uff0c\u5728 <code>resources\/views\/errors\/404.blade.php<\/code> \u4e2d\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!DOCTYPE html&gt;\n&lt;html&gt;\n&lt;head&gt;\n    &lt;title&gt;Page Not Found&lt;\/title&gt;\n&lt;\/head&gt;\n&lt;body&gt;\n    &lt;h1&gt;Oops! The page you are looking for could not be found.&lt;\/h1&gt;\n&lt;\/body&gt;\n&lt;\/html&gt;<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">3.2 <strong>\u5176\u4ed6\u9519\u8bef\u9875\u9762<\/strong><\/h4>\n\n\n\n<p>\u7c7b\u4f3c\u5730\uff0c\u4f60\u4e5f\u53ef\u4ee5\u4e3a\u5176\u4ed6\u5e38\u89c1\u7684\u9519\u8bef\uff08\u5982 500\u3001403 \u7b49\uff09\u521b\u5efa\u81ea\u5b9a\u4e49\u9875\u9762\u3002Laravel \u4f1a\u6839\u636e HTTP \u9519\u8bef\u4ee3\u7801\u81ea\u52a8\u52a0\u8f7d\u76f8\u5e94\u7684\u89c6\u56fe\u6587\u4ef6\uff0c\u5982 <code>errors\/500.blade.php<\/code>\u3001<code>errors\/403.blade.php<\/code> \u7b49\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">3.3 <strong>\u81ea\u5b9a\u4e49\u9519\u8bef\u9875\u9762\u6a21\u677f<\/strong><\/h4>\n\n\n\n<p>\u4f60\u53ef\u4ee5\u901a\u8fc7\u4f7f\u7528 Laravel \u7684\u89c6\u56fe\u7cfb\u7edf\uff0c\u5c06\u9519\u8bef\u9875\u9762\u6a21\u677f\u5316\uff0c\u4f7f\u5f97\u9875\u9762\u66f4\u7b26\u5408\u5e94\u7528\u7684\u6574\u4f53\u98ce\u683c\u3002<\/p>\n\n\n\n<p>\u4f8b\u5982\uff0c\u4f7f\u7528 <code>layouts\/app.blade.php<\/code> \u4f5c\u4e3a\u57fa\u5e03\u5c40\uff0c\u5e76\u5728 <code>errors\/404.blade.php<\/code> \u4e2d\u5f15\u5165\u8be5\u5e03\u5c40\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>@extends('layouts.app')\n\n@section('content')\n    &lt;div class=\"container\"&gt;\n        &lt;h1&gt;Oops! The page you are looking for could not be found.&lt;\/h1&gt;\n    &lt;\/div&gt;\n@endsection<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>\u56db\u3001\u65e5\u5fd7\u8bb0\u5f55<\/strong><\/h3>\n\n\n\n<p>Laravel \u4f7f\u7528 <strong>Monolog<\/strong> \u6765\u8bb0\u5f55\u5e94\u7528\u4e2d\u7684\u65e5\u5fd7\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0cLaravel \u5c06\u65e5\u5fd7\u5b58\u50a8\u5728 <code>storage\/logs<\/code> \u76ee\u5f55\u4e0b\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">4.1 <strong>\u65e5\u5fd7\u914d\u7f6e<\/strong><\/h4>\n\n\n\n<p>\u65e5\u5fd7\u7684\u914d\u7f6e\u6587\u4ef6\u4f4d\u4e8e <code>config\/logging.php<\/code>\u3002\u5728\u8fd9\u4e2a\u6587\u4ef6\u4e2d\uff0c\u4f60\u53ef\u4ee5\u914d\u7f6e\u4e0d\u540c\u7684\u65e5\u5fd7\u6e20\u9053\uff0c\u4f8b\u5982\u6587\u4ef6\u3001\u6570\u636e\u5e93\u3001\u90ae\u4ef6\u7b49\u3002Laravel \u652f\u6301\u591a\u79cd\u65e5\u5fd7\u5b58\u50a8\u65b9\u5f0f\uff0c\u5e38\u89c1\u7684\u6709\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u5355\u4e00\u65e5\u5fd7\u6587\u4ef6<\/strong>\uff1a\u5c06\u6240\u6709\u65e5\u5fd7\u5199\u5165\u540c\u4e00\u4e2a\u6587\u4ef6\u3002<\/li>\n\n\n\n<li><strong>\u6bcf\u65e5\u65e5\u5fd7\u6587\u4ef6<\/strong>\uff1a\u6bcf\u5929\u751f\u6210\u4e00\u4e2a\u65b0\u7684\u65e5\u5fd7\u6587\u4ef6\u3002<\/li>\n\n\n\n<li><strong>Slack\u3001HipChat\u3001Email \u7b49\u5916\u90e8\u901a\u77e5<\/strong>\uff1a\u5c06\u65e5\u5fd7\u4fe1\u606f\u63a8\u9001\u5230\u5916\u90e8\u5e73\u53f0\u3002<\/li>\n\n\n\n<li><strong>\u6570\u636e\u5e93\u65e5\u5fd7<\/strong>\uff1a\u5c06\u65e5\u5fd7\u8bb0\u5f55\u5b58\u50a8\u5728\u6570\u636e\u5e93\u4e2d\u3002<\/li>\n<\/ul>\n\n\n\n<p>\u4f8b\u5982\uff0c\u5c06\u65e5\u5fd7\u8bb0\u5f55\u5230\u6bcf\u65e5\u7684\u65e5\u5fd7\u6587\u4ef6\u4e2d\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>'channels' =&gt; &#91;\n    'daily' =&gt; &#91;\n        'driver' =&gt; 'daily',\n        'path' =&gt; storage_path('logs\/laravel.log'),\n        'level' =&gt; 'debug',\n        'days' =&gt; 14,\n    ],\n],<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">4.2 <strong>\u8bb0\u5f55\u5f02\u5e38\u548c\u9519\u8bef<\/strong><\/h4>\n\n\n\n<p>\u5728 <code>Handler<\/code> \u7c7b\u4e2d\uff0c\u4f60\u53ef\u4ee5\u901a\u8fc7 <code>report()<\/code> \u65b9\u6cd5\u8bb0\u5f55\u5f02\u5e38\u4fe1\u606f\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>public function report(Exception $exception)\n{\n    if ($exception instanceof NotFoundHttpException) {\n        Log::warning('Page not found: ' . $exception-&gt;getMessage());\n    }\n\n    parent::report($exception);\n}<\/code><\/pre>\n\n\n\n<p>\u4f60\u4e5f\u53ef\u4ee5\u901a\u8fc7\u624b\u52a8\u8c03\u7528 <code>Log<\/code> facade \u8bb0\u5f55\u5f02\u5e38\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>use Illuminate\\Support\\Facades\\Log;\n\ntry {\n    \/\/ \u53ef\u80fd\u629b\u51fa\u5f02\u5e38\u7684\u4ee3\u7801\n} catch (Exception $e) {\n    Log::error('An error occurred: ' . $e-&gt;getMessage());\n}<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">4.3 <strong>\u65e5\u5fd7\u7ea7\u522b<\/strong><\/h4>\n\n\n\n<p>Monolog \u63d0\u4f9b\u4e86\u4e0d\u540c\u7684\u65e5\u5fd7\u7ea7\u522b\uff0c\u5e2e\u52a9\u5f00\u53d1\u8005\u6839\u636e\u4e0d\u540c\u60c5\u51b5\u8bb0\u5f55\u4e0d\u540c\u4f18\u5148\u7ea7\u7684\u65e5\u5fd7\u4fe1\u606f\u3002\u5e38\u89c1\u7684\u65e5\u5fd7\u7ea7\u522b\u6709\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong><code>emergency<\/code><\/strong>\uff1a\u7cfb\u7edf\u5d29\u6e83\u6216\u4e25\u91cd\u9519\u8bef\u3002<\/li>\n\n\n\n<li><strong><code>alert<\/code><\/strong>\uff1a\u9700\u8981\u7acb\u5373\u5904\u7406\u7684\u95ee\u9898\u3002<\/li>\n\n\n\n<li><strong><code>critical<\/code><\/strong>\uff1a\u4e34\u754c\u95ee\u9898\u3002<\/li>\n\n\n\n<li><strong><code>error<\/code><\/strong>\uff1a\u9519\u8bef\u4fe1\u606f\u3002<\/li>\n\n\n\n<li><strong><code>warning<\/code><\/strong>\uff1a\u8b66\u544a\u4fe1\u606f\u3002<\/li>\n\n\n\n<li><strong><code>info<\/code><\/strong>\uff1a\u4e00\u822c\u4fe1\u606f\u3002<\/li>\n\n\n\n<li><strong><code>debug<\/code><\/strong>\uff1a\u8c03\u8bd5\u4fe1\u606f\u3002<\/li>\n<\/ul>\n\n\n\n<p>\u4f60\u53ef\u4ee5\u6839\u636e\u9700\u6c42\u8c03\u6574\u65e5\u5fd7\u7ea7\u522b\uff0c\u4f8b\u5982\u5728\u5f00\u53d1\u73af\u5883\u4e2d\u8bb0\u5f55\u66f4\u591a\u7684\u8c03\u8bd5\u4fe1\u606f\uff0c\u5728\u751f\u4ea7\u73af\u5883\u4e2d\u4ec5\u8bb0\u5f55\u8b66\u544a\u6216\u9519\u8bef\u4fe1\u606f\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>\u4e94\u3001\u5f02\u5e38\u62a5\u544a\u4e0e\u76d1\u63a7<\/strong><\/h3>\n\n\n\n<p>Laravel \u5141\u8bb8\u5c06\u5f02\u5e38\u62a5\u544a\u5230\u5916\u90e8\u9519\u8bef\u8ddf\u8e2a\u7cfb\u7edf\uff0c\u5982 <strong>Sentry<\/strong>\u3001<strong>Bugsnag<\/strong> \u7b49\u3002\u8fd9\u4e9b\u5de5\u5177\u80fd\u591f\u5e2e\u52a9\u5f00\u53d1\u8005\u53ca\u65f6\u6355\u6349\u5e76\u54cd\u5e94\u751f\u4ea7\u73af\u5883\u4e2d\u7684\u9519\u8bef\u3002<\/p>\n\n\n\n<p>\u4f60\u53ef\u4ee5\u901a\u8fc7\u5b89\u88c5 Laravel \u7684\u5b98\u65b9\u96c6\u6210\u5305\uff0c\u50cf\u662f <strong>Sentry<\/strong> \u6216 <strong>Bugsnag<\/strong>\uff0c\u5e76\u5728 <code>config\/app.php<\/code> \u4e2d\u8fdb\u884c\u914d\u7f6e\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ \u914d\u7f6e Sentry\nSentry\\Laravel\\ServiceProvider::class,<\/code><\/pre>\n\n\n\n<p>\u5b89\u88c5\u5b8c\u6bd5\u540e\uff0c\u6240\u6709\u672a\u6355\u83b7\u7684\u5f02\u5e38\u90fd\u4f1a\u81ea\u52a8\u53d1\u9001\u5230\u5916\u90e8\u7cfb\u7edf\u8fdb\u884c\u76d1\u63a7\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>\u516d\u3001\u603b\u7ed3<\/strong><\/h3>\n\n\n\n<p>Laravel \u63d0\u4f9b\u4e86\u5f3a\u5927\u7684\u9519\u8bef\u5904\u7406\u673a\u5236\uff0c\u901a\u8fc7\u7075\u6d3b\u7684\u5f02\u5e38\u6355\u83b7\u3001\u65e5\u5fd7\u8bb0\u5f55\u548c\u81ea\u5b9a\u4e49\u9519\u8bef\u9875\u9762\u529f\u80fd\uff0c\u5e2e\u52a9\u5f00\u53d1\u8005\u6784\u5efa\u7a33\u5b9a\u4e14\u7528\u6237\u53cb\u597d\u7684\u5e94\u7528\u7a0b\u5e8f\u3002\u901a\u8fc7\u4e8b\u4ef6\u6355\u83b7\u3001\u5f02\u5e38\u5904\u7406\u3001\u65e5\u5fd7\u8bb0\u5f55\u4ee5\u53ca\u4e0e\u5916\u90e8\u76d1\u63a7\u5de5\u5177\u7684\u96c6\u6210\uff0cLaravel \u80fd\u591f\u6709\u6548\u5730\u5e94\u5bf9\u751f\u4ea7\u73af\u5883\u4e2d\u7684\u5404\u79cd\u5f02\u5e38\u548c\u9519\u8bef\uff0c\u63d0\u5347\u5e94\u7528\u7684\u53ef\u9760\u6027\u548c\u7528\u6237\u4f53\u9a8c\u3002<\/p>\n\n\n\n<p>Laravel \u7684\u9519\u8bef\u5904\u7406\u4e0d\u4ec5\u9650\u4e8e\u6355\u83b7\u548c\u8bb0\u5f55\u9519\u8bef\uff0c\u8fd8\u5305\u62ec\u4e3a\u7528\u6237\u63d0\u4f9b\u4e2a\u6027\u5316\u7684\u9519\u8bef\u54cd\u5e94\uff0c\u786e\u4fdd\u7528\u6237\u5728\u9047\u5230\u95ee\u9898\u65f6\u4e0d\u4f1a\u611f\u5230\u56f0\u60d1\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Laravel &#8211; \u9519\u8bef\u5904\u7406\uff1a\u5168\u9762\u89e3\u6790\u4e0e\u6700\u4f73\u5b9e\u8df5 \u5728 Laravel \u4e2d\uff0c\u9519\u8bef\u5904\u7406\u662f\u5e94\u7528\u7a0b\u5e8f\u5f00\u53d1\u7684 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[62],"tags":[],"class_list":["post-1059","post","type-post","status-publish","format-standard","hentry","category-laravel"],"_links":{"self":[{"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/posts\/1059","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/comments?post=1059"}],"version-history":[{"count":1,"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/posts\/1059\/revisions"}],"predecessor-version":[{"id":1060,"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/posts\/1059\/revisions\/1060"}],"wp:attachment":[{"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/media?parent=1059"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/categories?post=1059"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/tags?post=1059"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}