承接 rnr1721/le7-http-client 相关项目开发

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

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

rnr1721/le7-http-client

最新稳定版本:1.0.1

Composer 安装命令:

composer require rnr1721/le7-http-client

包简介

PSR Http-client for le7 PHP MVC framework or any PSR project

README 文档

README

Http client client for le7 PHP MVC framework or any PSR project This is an simple PSR http-client implementation

API Request Utility

This project provides HTTP clients that uses Curl and standard PHP functions to make requests.

What it can?

  • Create HTTP requests using cURL
  • Create HTTP requests using standard PHP tools

Requirements

  • PHP 8.0 or higher
  • Composer (for installing dependencies)

Installation

  1. Install via composer:
composer require rnr1721/le7-http-client

Testing

composer test

Usage

In this example, I use Nyholm PSR library, but you can use any, Guzzle for example

Get ClientInterface object (httpClient)

use Nyholm\Psr7\Factory\Psr17Factory;
use Core\HttpClient\HttpClientCurl;
use Core\HttpClient\HttpClientDefault;

// Create PSR factories. Nyholm realisation is a single factory to all
$psr17Factory = new Psr17Factory();

// Get Curl http client
$httpClientCurl = new HttpClientCurl(
    $psr17Factory // ResponseFactoryInterface
)

// Or if need get PHP http client
$httpClientPhp = new HttpClientDefault(
    $psr17Factory // ResponseFactoryInterface
)

// now we can use it:

$request = $psr17Factory->createRequest('GET', 'http://tnyholm.se');

$response = $httpClientCurl->sendRequest($request);

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-05-22