Skip to content

Commit 112e871

Browse files
committed
Add description to README.md
1 parent cd18616 commit 112e871

File tree

1 file changed

+67
-1
lines changed

1 file changed

+67
-1
lines changed

README.md

Lines changed: 67 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,69 @@
11
# HTTP Error Handler
22

3-
The repository is under development, and the description will appear later.
3+
[![License](https://poser.pugx.org/httpsoft/http-error-handler/license)](https://packagist.org/packages/httpsoft/http-error-handler)
4+
[![Latest Stable Version](https://poser.pugx.org/httpsoft/http-error-handler/v)](https://packagist.org/packages/httpsoft/http-error-handler)
5+
[![Total Downloads](https://poser.pugx.org/httpsoft/http-error-handler/downloads)](https://packagist.org/packages/httpsoft/http-error-handler)
6+
[![GitHub Build Status](https://github.com/httpsoft/http-error-handler/workflows/build/badge.svg)](https://github.com/httpsoft/http-error-handler/actions)
7+
[![Scrutinizer Code Coverage](https://scrutinizer-ci.com/g/httpsoft/http-error-handler/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/httpsoft/http-error-handler/?branch=master)
8+
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/httpsoft/http-error-handler/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/httpsoft/http-error-handler/?branch=master)
9+
10+
This package implements [Psr\Http\Server\MiddlewareInterface](https://github.com/php-fig/http-server-middleware/blob/master/src/MiddlewareInterface.php) and [Psr\Http\Server\RequestHandlerInterface](https://github.com/php-fig/http-server-handler/blob/master/src/RequestHandlerInterface.php).
11+
12+
## Documentation
13+
14+
* [In English language](https://httpsoft.org/docs/error-handler).
15+
* [In Russian language](https://httpsoft.org/ru/docs/error-handler).
16+
17+
## Installation
18+
19+
This package requires PHP version 7.4 or later.
20+
21+
```
22+
composer require httpsoft/http-error-handler
23+
```
24+
25+
## Usage ErrorHandler
26+
27+
```php
28+
use HttpSoft\ErrorHandler\ErrorHandler;
29+
30+
/**
31+
* @var Psr\Http\Message\ServerRequestInterface $request
32+
* @var Psr\Http\Server\RequestHandlerInterface $handler
33+
*
34+
* @var HttpSoft\ErrorHandler\ErrorListenerInterface $logErrorListener
35+
* @var HttpSoft\ErrorHandler\ErrorListenerInterface $sendErrorListener
36+
* @var HttpSoft\ErrorHandler\ErrorResponseGeneratorInterface $responseGenerator
37+
*/
38+
39+
$errorHandler = new ErrorHandler($handler, $responseGenerator);
40+
41+
$errorHandler->addListener($logErrorListener);
42+
$errorHandler->addListener($sendErrorListener);
43+
44+
/** @var \Psr\Http\Message\ResponseInterface $response */
45+
$response = $errorHandler->handle($request);
46+
```
47+
48+
## Usage ErrorHandlerMiddleware
49+
50+
```php
51+
use HttpSoft\ErrorHandler\ErrorHandlerMiddleware;
52+
53+
/**
54+
* @var Psr\Http\Message\ServerRequestInterface $request
55+
* @var Psr\Http\Server\RequestHandlerInterface $handler
56+
*
57+
* @var HttpSoft\ErrorHandler\ErrorListenerInterface $logErrorListener
58+
* @var HttpSoft\ErrorHandler\ErrorListenerInterface $sendErrorListener
59+
* @var HttpSoft\ErrorHandler\ErrorResponseGeneratorInterface $responseGenerator
60+
*/
61+
62+
$errorHandler = new ErrorHandlerMiddleware($responseGenerator);
63+
64+
$errorHandler->addListener($logErrorListener);
65+
$errorHandler->addListener($sendErrorListener);
66+
67+
/** @var \Psr\Http\Message\ResponseInterface $response */
68+
$response = $errorHandler->process($request, $handler);
69+
```

0 commit comments

Comments
 (0)