PHP code example of goedemiddag / request-response-log
1. Go to this page and download the library: Download goedemiddag/request-response-log 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/ */
goedemiddag / request-response-log example snippets
use Goedemiddag\RequestResponseLog\RequestResponseLogger;
use Illuminate\Support\Facades\Http;
Http::withMiddleware(RequestResponseLogger::middleware('vendor'))
use Goedemiddag\RequestResponseLog\RequestResponseLogger;
use GuzzleHttp\Client;
use GuzzleHttp\HandlerStack;
use GuzzleHttp\Handler\CurlHandler;
$stack = new HandlerStack();
$stack->setHandler(new CurlHandler());
$stack->push(RequestResponseLogger::middleware('vendor'));
$client = new Client(['handler' => $stack]);
use Goedemiddag\RequestResponseLog\RequestResponseLogger;
use Saloon\Http\Connector;
class YourConnector extends Connector
{
public function __construct()
{
$this
->sender()
->addMiddleware(RequestResponseLogger::middleware('vendor'));
}
}
use Goedemiddag\RequestResponseLog\Enums\RequestFlow;
use Goedemiddag\RequestResponseLog\ManualRequestResponseLogger;
$requestLog = ManualRequestResponseLogger::fromRequest(
vendor: 'vendor',
request: $request,
flow: RequestFlow::Incoming,
);
// TODO your code here
ManualRequestResponseLogger::fromResponse(
requestLog: $requestLog,
response: $response,
);
use Goedemiddag\RequestResponseLog\Models\RequestLog;
use Illuminate\Support\Facades\Schedule;
Schedule::command('model:prune', ['--model' => [RequestLog::class]])->daily();
use Goedemiddag\RequestResponseLog\Models\RequestLog;
$schedule
->command('model:prune', ['--model' => [RequestLog::class]])
->daily();