PHP code example of malvik-lab / guzzle-log-middleware
1. Go to this page and download the library: Download malvik-lab/guzzle-log-middleware library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
malvik-lab / guzzle-log-middleware example snippets
// composer new \Laminas\Log\Writer\Stream('/path/to/log/file.log');
$laminasLogLogger = new \Laminas\Log\Logger();
$laminasLogLogger->addWriter($writer);
$log = new \Laminas\Log\PsrLoggerAdapter($laminasLogLogger);
$adapter = [
'adapter' => $log,
'options' => [
'template' => \GuzzleHttp\MessageFormatter::CLF, // Not mandatory. For more information: https://github.com/guzzle/guzzle/blob/master/src/MessageFormatter.php
]
];
$adapter = [
'adapter' => 'filesystem',
'options' => [
'dirPath' => '/path/to/log/folder',
'template' => \GuzzleHttp\MessageFormatter::CLF, // Not mandatory. For more information: https://github.com/guzzle/guzzle/blob/master/src/MessageFormatter.php
]
];
$adapter = [
'adapter' => 'filesystem',
'options' => [
'filePath' => '/path/to/log/file.log',
'template' => \GuzzleHttp\MessageFormatter::CLF, // Not mandatory. For more information: https://github.com/guzzle/guzzle/blob/master/src/MessageFormatter.php
]
];
// In the constructor you can inject one or more adapters
$guzzleLogMiddleware = new \MalvikLab\GuzzleLogMiddleware\GuzzleLogMiddleware([
$adapter
]);
$stack = \GuzzleHttp\HandlerStack::create();
$stack->push($guzzleLogMiddleware);
// your client
$client = new \GuzzleHttp\Client([
'handler' => $stack
]);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.