Skip to content

Commit e1d0f75

Browse files
committedAug 31, 2015
Update README.md
1 parent 4b9c200 commit e1d0f75

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed
 

Diff for: ‎README.md

+38
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,40 @@
11
# log-http-messages middleware [![Build Status](https://travis-ci.org/php-middleware/log-http-messages.svg)](https://travis-ci.org/php-middleware/log-http-messages)
22
Request and response middleware logger with PSR-7 and PSR-3
3+
4+
This middleware provide framework-agnostic possibility to log request and response messages to PSR-3 logger.
5+
6+
## Installation
7+
8+
```json
9+
{
10+
"require": {
11+
"php-middleware/log-http-messages": "^1.0.0"
12+
}
13+
}
14+
```
15+
16+
To log any request you need pass into `LogRequestMiddleware` instance `Psr\Log\LoggerInterface` and add middleware to your middleware runner. To log response use `LogResponseMiddleware`.
17+
18+
```php
19+
$logRequestMiddleware = new PhpMiddleware\LogHttpMessages\LogRequestMiddleware($logger);
20+
$logResponseMiddleware = new PhpMiddleware\LogHttpMessages\LogResponseMiddleware($logger);
21+
22+
$app = new MiddlewareRunner();
23+
$app->add($logRequestMiddleware);
24+
$app->add($logResponseMiddleware);
25+
$app->run($request, $response);
26+
```
27+
28+
Middlewares have optional second parameter in constructor with log level (default `Psr\Log\LogLevel::INFO`).
29+
30+
## It's just works with any modern php framework and logger!
31+
32+
Middleware tested on:
33+
* [Expressive](https://github.com/zendframework/zend-expressive)
34+
* [monolog](https://github.com/Seldaek/monolog)
35+
36+
Middleware should works with:
37+
* [Slim 3.x](https://github.com/slimphp/Slim)
38+
* [zend-log 2.6](https://github.com/zendframework/zend-log)
39+
40+
And any other modern framework [supported middlewares and PSR-7](https://mwop.net/blog/2015-01-08-on-http-middleware-and-psr-7.html) and [PSR-3 implementation](http://www.php-fig.org/psr/psr-3/) logger.

0 commit comments

Comments
 (0)