PHP code example of quansitech / qscmf-http-tracer

1. Go to this page and download the library: Download quansitech/qscmf-http-tracer 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/ */

    

quansitech / qscmf-http-tracer example snippets


use Qscmf\HttpTracer\Client\GuzzleClient;
use Qscmf\HttpTracer\Lib\LogWriter\Context;

// 创建日志记录器(数据库存储)
$writer = Context::buildWriter('db');
$logger = new RequestLogger($writer);

// 创建带追踪的 HTTP 客户端
$client = (new GuzzleClient($logger))->create([]);

// 发送 GET 请求
$response = $client->request('GET', 'https://api.example.com/users');

use Qscmf\HttpTracer\Client\GuzzleClient;
use Qscmf\HttpTracer\Lib\LogWriter\Context;

// 创建日志记录器(文件存储)
$writer = Context::buildWriter('file');
$logger = new RequestLogger($writer);

// 创建带追踪的 HTTP 客户端
$client = (new GuzzleClient($logger))->create([]);

// 发送请求
$response = $client->request('GET', 'https://api.example.com/users');
bash
php artisan migrate