vmpublishing/psr15-middleware-error-handler
Composer 安装命令:
composer require vmpublishing/psr15-middleware-error-handler
包简介
dependency-less middleware to capture and process any throwable with a dedicated error handler
README 文档
README
WHAT
PSR-15 error handling middleware with as low dependencies as possible.
for productive use we like a middleware that captures and processes error into a nicer format (if possible)
this comes with two handler implementations. one just rethrow the error (for development purposes) one responds with the contents of a predefined file and a correct status code (for production use)
INSTALL
To install simply use
composer require vmpublishing/psr15-middleware-error-handler:*@stable
USE
This is quite simple: define your handler and add the middleware;
use VM\ErrorHandler\Services\RethrowHandler;
$handler = new RethrowHandler();
$middleware = new ErrorProcessor($handler);
// and for slim, given $app
$app->add($middleware);
// or just add it on the routes you want it on
For the StaticFileHandler you need to pass in at least one file and an empty Response object;
use VM\ErrorHandler\Services\StaticFileHandler;
$handler = new StaticFileHandler('/path/to/500.html', $emptyResponse);
$middleware = new ErrorProcessor($handler);
// and for slim, given $app
$app->add($middleware);
// ...
To have specific ErrorCodes, you need to use the Http Exceptions from this library, ie: NotFound
统计信息
- 总下载量: 381
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-06-18