Use rmccue/requests as a PSR-18 HTTP client

Overview

WordPress/Requests PSR-18 Adapter

Use WordPress/Requests as a PSR-18 HTTP client adapter.

Requires PHP 7.1+

Why?

Requests is a HTTP library written in PHP, that lacks of support for PSR-7 and also for PSR-18 because of the compatability with PHP 5.6+.

I've created a PR in Requests to add PSR-7 support but I would be able to use it today. So I created this library. If one day Requests nativly supports PSR-7 and PSR-18, this library will become obsolete.

How to use

Installation with Composer

WordPress/Requests PSR-18 Adapter is available on Packagist and can be installed using Composer.

composer require art4/requests-psr18-adapter

Example

<?php

// First, include the Composer autoload.php
require_once dirname(__DIR__) . '/vendor/autoload.php';

// Define Requests options
$options = [
    'proxy' => '127.0.0.1:8080',
    'transport' => $customTransport,
    // other Requests options
];

// Create the HTTP client
$httpClient = new \Art4\Requests\Psr\HttpClient($options);

// Create a PSR-7 request and optional set other headers
$request = $httpClient->createRequest('GET', 'http://httpbin.org/get');
$request = $request->withHeader('Accept', 'application/json');

try {
    // Send the request
    $response = $httpClient->sendRequest($request);
} catch (\Psr\Http\Client\ClientExceptionInterface $th) {
    // Handle errors
    throw $th;
}

// Use the PSR-7 Response
var_dump($response);
You might also like...
oursms.app client library that allows you to send SMS

Oursms laravel client https://oursms.app client library that allows you to send SMS Installation Install oursms client with composer composer requir

Xendit REST API Client for PHP - Card, Virtual Account, Invoice, Disbursement, Recurring Payments, Payout, EWallet, Balance, Retail Outlets Services

Xendit REST API Client for PHP - Card, Virtual Account, Invoice, Disbursement, Recurring Payments, Payout, EWallet, Balance, Retail Outlets Services

PHP client for Kafka

A library to allow people to communicate to Kafka using plain PHP, compatible with Kafka v0.11+ (due to the way the protocol works).

DigitalOcean API v2 client for Symfony and API Platform

DigitalOcean Bundle for Symfony and API Platform DunglasDigitalOceanBundle allows using the DigitalOcean API from your Symfony and API Platform projec

php 8 client for the lemon.markets api

lemon.markets php client This repository contains a php 8+ compatible client for the https://lemon.markets API. The documentation of the API can be fo

PHP client for Microsoft Azure Face API.

Microsoft Azure Face API PHP client A PHP library that utilizes Azure Face REST API. Requirements PHP = 7.4 Installation composer require darmen/php-

Google PHP API Client Services

Google PHP API Client Services

AltiriaSmsPhpClient, the official PHP client of Altiria
AltiriaSmsPhpClient, the official PHP client of Altiria

Altiria, cliente SMS PHP Altiria SMS PHP es un cliente que simplifica al máximo la integración de nuestro API para PHP. Por el momento, esta librería

A2Reviews Client API lets you build apps, extensions or plugins to get reviews from the A2reviews APP
A2Reviews Client API lets you build apps, extensions or plugins to get reviews from the A2reviews APP

A2Reviews Client API lets you build apps, extensions or plugins to get reviews from the A2reviews APP. Including adding reviews to a store's products. It is used to import and export reviews through the API. This is the official package built and developed by A2Reviews, Inc.

Releases(1.0.0)
Owner
Artur Weigandt
Artur Weigandt
json-rpc client base on http

laravel JSON-RPC客户端(Http协议) 本项目是基于JSON-RPC的服务端端实现的rpc客户端 server端见:https://sajya.github.io/ 初始化 发布 php artisan vendor:publish --provider="Ze\JsonRpcCli

Zeee 2 Nov 19, 2021
json-rpc client base on http

laravel JSON-RPC客户端(Http协议) 本项目是基于JSON-RPC的服务端端实现的rpc客户端 server端见:https://sajya.github.io/ 初始化 1.发布 php artisan vendor:publish --provider="Ze\JsonRPCC

null 2 Nov 19, 2021
SendGrid's PHP HTTP Client for calling APIs

Quickly and easily access any RESTful or RESTful-like API. If you are looking for the SendGrid API client library, please see this repo. Announcements

Twilio SendGrid 119 Nov 25, 2022
HTTP Requestor: Package for a client request that supports you to make an external service request easily and with fast usage.

HttpRequestor from Patienceman HTTP Requestor: Package for a client request that supports you to make an external service request easily and with fast

Manirabona Patience 2 Aug 26, 2022
Google-api-php-client - A PHP client library for accessing Google APIs

Google APIs Client Library for PHP Reference Docs https://googleapis.github.io/google-api-php-client/main/ License Apache 2.0 The Google API Client Li

Google APIs 8.4k Dec 30, 2022
PHP JSON-RPC 2.0 Server/Client Implementation with Automatic Client Class Generation via SMD

PHP JSON-RPC 2.0 Server/Client Implementation with Automatic Client Class Generation via SMD

Sergey Bykov 63 Feb 14, 2022
OpenAI API Client is a component-oriented, extensible client library for the OpenAI API. It's designed to be faster and more memory efficient than traditional PHP libraries.

OpenAI API Client in PHP (community-maintained) This library is a component-oriented, extensible client library for the OpenAI API. It's designed to b

Mounir R'Quiba 6 Jun 14, 2023
PSR-18 compliant Circuit Breaker wrapper

Interrupt PSR-18 compliant Circuit Breaker wrapper. Acknowledgement This library is heavily inspired by: ackintosh/ganesha PrestaShop/circuit-breaker

Flávio Heleno 5 Jun 14, 2023
A simple PHP GitHub API client, Object Oriented, tested and documented.

PHP GitHub API A simple Object Oriented wrapper for GitHub API, written with PHP. Uses GitHub API v3 & supports GitHub API v4. The object API (v3) is

KNP Labs 2k Jan 7, 2023
A simple Object Oriented PHP Client for Termii SMS API

Termii Client A simple Object Oriented PHP Client for Termii SMS API. Uses Termii API. Requirements PHP >= 7.2 Guzzlehttp ~6|~7 Installation Via Compo

Ilesanmi Olawale Adedotun 5 Feb 24, 2022