stratify / error-handler-module

Stratify 错误处理模块

0.5.0 2017-08-05 19:33 UTC

This package is auto-updated.

Last update: 2024-09-19 21:03:56 UTC


README

安装

    1. 安装此包
composer require stratify/error-handler-module
    1. 启用模块
$app = new Application([
    'stratify/error-handler-module',
]);
    1. 使用 HTTP 中间件
$http = pipe([
    ErrorHandlerMiddleware::class,

    // ...
]);
$app->http($http)->run();

HTTP 中间件会捕获子中间件中发生的所有异常并显示错误页面。因此,您可能希望该中间件在所有其他中间件之前运行。

默认行为是显示一个非常简单的错误页面:服务器错误(状态码 500)。

dev 环境中,由于 Whoops 库的帮助,错误页面将更加详细。出于安全原因(不暴露任何敏感信息),此页面仅在您将应用程序配置为在 dev 环境中运行时才显示。

$app = new Application($modules, 'dev');