tony-sol/symfony-api-client 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

tony-sol/symfony-api-client

最新稳定版本:v1.0.0

Composer 安装命令:

composer require tony-sol/symfony-api-client

包简介

HTTP Client for any external APIs

README 文档

README

Required configuration example

ApiClient\Service\ApiClient:
    class: ApiClient\Service\ApiClient
    arguments:
        $httpClient: '@GuzzleHttp\ClientInterface'

ApiClient\Service\ApiClientInterface: '@ApiClient\Service\ApiClient'

Usage example

private \ApiClient\Service\ApiClientInterface $apiClient;

public function __construct(\ApiClient\Service\ApiClientInterface $apiClient)
{
    $this->apiClient = $apiClient;
}

public function sendGet()
{
    // curl --location --request GET 'http://example.org/endpoint?some=data'
    $response = $this->apiClient
        ->makeGetClient('http://example.org/endpoint')
        ->withResponseAs(Example\EndpoindDTO::class)
        ->withRequest(['some' => 'data',])
        ->send();

    /** @var int $responseCode */
    $responseCode = $response->getCode();
    /** @var array<string, string> $responseHeaders */
    $responseHeaders = $response->getHeaders();
    /** @var Example\EndpoindDTO $responseDTO */
    $responseDTO = $response->getResponse();
    return;
}

public function sendPost()
{
    // curl --location --request POST 'http://example.org/endpoint' --header 'Content-Type: application/json' --data-raw '{"some": "data"}'
    $response = $this->apiClient
        ->makePostClient('http://example.org/endpoint')
        ->withResponseAs(Example\EndpoindDTO::class)
        ->withRequest(['some' => 'data',])
        ->send();

    /** @var int $responseCode */
    $responseCode = $response->getCode();
    /** @var array<string, string> $responseHeaders */
    $responseHeaders = $response->getHeaders();
    /** @var Example\EndpoindDTO $responseDTO */
    $responseDTO = $response->getResponse();
    return;
}

Disclaimer

All information and source code are provided AS-IS, without express or implied warranties. Use of the source code or parts of it is at your sole discretion and risk. Citymobil LLC takes reasonable measures to ensure the relevance of the information posted in this repository, but it does not assume responsibility for maintaining or updating this repository or its parts outside the framework established by the company independently and without notifying third parties.

Вся информация и исходный код предоставляются в исходном виде, без явно выраженных или подразумеваемых гарантий. Использование исходного кода или его части осуществляются исключительно по вашему усмотрению и на ваш риск. Компания ООО "Ситимобил" принимает разумные меры для обеспечения актуальности информации, размещенной в данном репозитории, но она не принимает на себя ответственности за поддержку или актуализацию данного репозитория или его частей вне рамок, устанавливаемых компанией самостоятельно и без уведомления третьих лиц.

统计信息

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

GitHub 信息

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

其他信息

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

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固