stratify / error-handler-module
Stratify 错误处理模块
0.5.0
2017-08-05 19:33 UTC
Requires
- filp/whoops: ^2.0
- php-di/php-di: ^6.0.0-alpha4
- psr/container: ^1.0
- psr/http-message: ^1.0
- psr/log: ^1.0
- stratify/http: ~0.5.0
Requires (Dev)
- phpunit/phpunit: ^5.2
- zendframework/zend-diactoros: ^1.3
README
安装
-
- 安装此包
composer require stratify/error-handler-module
-
- 启用模块
$app = new Application([ 'stratify/error-handler-module', ]);
-
- 使用 HTTP 中间件
$http = pipe([ ErrorHandlerMiddleware::class, // ... ]); $app->http($http)->run();
HTTP 中间件会捕获子中间件中发生的所有异常并显示错误页面。因此,您可能希望该中间件在所有其他中间件之前运行。
默认行为是显示一个非常简单的错误页面:服务器错误
(状态码 500)。
在 dev
环境中,由于 Whoops 库的帮助,错误页面将更加详细。出于安全原因(不暴露任何敏感信息),此页面仅在您将应用程序配置为在 dev
环境中运行时才显示。
$app = new Application($modules, 'dev');