承接 setono/request-aware-http-client 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

setono/request-aware-http-client

最新稳定版本:v1.1.0

Composer 安装命令:

composer require setono/request-aware-http-client

包简介

A library that decorates the http client with request logging

README 文档

README

Latest Version Software License Build Status Code Coverage

This library will decorate Symfony HTTP client and make it possible to retrieve full requests for debugging etc.

Installation

Step 1: Download

composer require setono/request-aware-http-client

Usage

<?php
use Setono\RequestAwareHttpClient\RequestAwareHttpClient;
use Setono\RequestAwareHttpClient\RequestAwareHttpClientInterface;
use Symfony\Contracts\HttpClient\HttpClientInterface;

class YourService
{
    private RequestAwareHttpClientInterface $httpClient;
    
    public function __construct(HttpClientInterface $httpClient)
    {
        $this->httpClient = new RequestAwareHttpClient($httpClient);
    }
    
    public function doSomething(): void
    {
        $response = $this->httpClient->request('POST', 'https://httpbin.org/post', [
            'json' => ['name' => 'John Doe']
        ]);

        $request = $this->httpClient->getRequest($response);

        echo $request->toString();
        
        // Outputs:
        // POST https://httpbin.org/post
        // {
        //     "name": "John Doe"
        // }
    }
}

统计信息

  • 总下载量: 3.96k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-09-16