PHPackages                             art4/requests-psr18-adapter - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. art4/requests-psr18-adapter

ActiveLibrary[HTTP &amp; Networking](/categories/http)

art4/requests-psr18-adapter
===========================

Use WordPress/Requests as a PSR-18 HTTP client

1.4.1(1mo ago)157.1k5[2 PRs](https://github.com/Art4/WP-Requests-PSR18-Adapter/pulls)GPL-3.0-or-laterPHPPHP ^7.2 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0 || ~8.5.0

Since Oct 6Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/Art4/WP-Requests-PSR18-Adapter)[ Packagist](https://packagist.org/packages/art4/requests-psr18-adapter)[ Docs](https://github.com/Art4/WP-Requests-PSR18-Adapter)[ RSS](/packages/art4-requests-psr18-adapter/feed)WikiDiscussions main Synced 2d ago

READMEChangelog (9)Dependencies (26)Versions (16)Used By (0)

WordPress/Requests PSR-18 Adapter
=================================

[](#wordpressrequests-psr-18-adapter)

[![Latest Version](https://camo.githubusercontent.com/ab77aa24e46a8464c874beb290622bdb233f376a64835910ead869da1a366951/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f417274342f57502d52657175657374732d50535231382d416461707465722e737667)](https://github.com/Art4/WP-Requests-PSR18-Adapter/releases)[![Software License](https://camo.githubusercontent.com/6f2b03e518f71117284f01a8bf089395fa6c9400661b197d9b9be1919550b944/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d47504c332d627269676874677265656e2e737667)](LICENSE.md)[![Build Status](https://github.com/Art4/WP-Requests-PSR18-Adapter/actions/workflows/tests.yml/badge.svg?branch=main)](https://github.com/Art4/WP-Requests-PSR18-Adapter/actions)[![codecov](https://camo.githubusercontent.com/7ebeb8a42fcbc073fdf0737b302c8c415c4adf85309cad3862f12fa3d58eca2e/68747470733a2f2f636f6465636f762e696f2f67682f417274342f57502d52657175657374732d50535231382d416461707465722f6272616e63682f6d61696e2f67726170682f62616467652e7376673f746f6b656e3d4e57574a5847364d494c)](https://codecov.io/gh/Art4/WP-Requests-PSR18-Adapter)[![Total Downloads](https://camo.githubusercontent.com/37122aa17084a26d0591127720ae0627566feabb9ba9e2f0cf05c025eacb715b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f617274342f72657175657374732d70737231382d616461707465722e737667)](https://packagist.org/packages/art4/requests-psr18-adapter)

Use [WordPress/Requests](https://github.com/WordPress/Requests) as a [PSR-18](https://www.php-fig.org/psr/psr-18/) HTTP client adapter.

- Requires PHP 7.2+
- Supports Requests v1.8+ and v2

Why?
----

[](#why)

Requests is a HTTP library written in PHP, that [lacks of support for PSR-7](https://github.com/WordPress/Requests/issues/320) 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](https://github.com/WordPress/Requests/pull/768) but this would add new direct dependencies to Requests. So I created this library as an optional wrapper for Requests. If one day Requests nativly supports PSR-7 and PSR-18, this library might become obsolete.

How to use
----------

[](#how-to-use)

### Installation with Composer

[](#installation-with-composer)

WordPress/Requests PSR-18 Adapter is [available on Packagist](https://packagist.org/packages/art4/requests-psr18-adapter) and can be installed using [Composer](https://getcomposer.org/).

```
composer require art4/requests-psr18-adapter
```

If you want to use WordPress/Requests PSR-18 Adapter in context of a WordPress instance (e.g. in a plugin or theme) you should add `"rmccue/requests": "*"` as a `replace` package link. This will prevent composer from installing `rmccue/requests` two times, leading to fatal errors.

Example `composer.json`:

```
{
    "require": {
        "art4/requests-psr18-adapter": "^1.1"
    },
    "replace": {
        "rmccue/requests": "*"
    }
}
```

### Examples

[](#examples)

Take a look at the [examples directory](examples/) for more examples.

```
