alextartan/guzzle-psr18-adapter

基于Guzzle的轻量级包装,以符合PSR18规范

4.0.4 2021-01-01 00:13 UTC

README

PSR-18的Guzzle适配器

符合PSR-18规范的Guzzle包装器

当前构建状态

CI codecov Infection MSI Downloads

安装

最简单的方法是使用composer

composer require alextartan/guzzle-psr18-adapter

注意:需要PHP >= 7.2

使用方法

示例

<?php

use Psr\Http\Client\ClientInterface;
use Psr\Http\Client\ClientExceptionInterface;
use Psr\Http\Client\NetworkExceptionInterface;
use Psr\Http\Client\RequestExceptionInterface;
use GuzzleHttp\Psr7\Request;

[...]

public function sendSomething(ClientInterface $client, $data)
{
    // Using GuzzleHttp\Psr7\Request in this example, but any implementation of PSR-7 will do
    $request = new Request('GET', 'https://some-domain.com/something');
    try{
        // response is also an implementation of PSR-7 (Psr\Http\Message\ResponseInterface)
        $response = $client->sendRequest($request)
    } catch(ClientException $e){
        // do something
    } catch(NetworkException $e){
        // do something
    } catch(RequestException $e){
        // do something
    }
}

[...]

问题和pull请求。

发现任何问题应在此存储库问题跟踪器中报告,问题将在可能的情况下得到解决。将接受pull请求,但请遵守PSR2编码标准。所有构建必须通过才能合并PR。