PHPackages                             jdriscoll/curl-psr - 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. jdriscoll/curl-psr

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

jdriscoll/curl-psr
==================

A utility for using PSR-7 Request and Response objects with Curl

v2.0.0(5mo ago)0301BSD-2-ClausePHPPHP ^8.5

Since May 18Pushed 5mo ago1 watchersCompare

[ Source](https://github.com/jj101k/curl-psr)[ Packagist](https://packagist.org/packages/jdriscoll/curl-psr)[ RSS](/packages/jdriscoll-curl-psr/feed)WikiDiscussions main Synced 2w ago

READMEChangelogDependencies (2)Versions (12)Used By (1)

Overview
========

[](#overview)

This lets you run Curl requests with PSR-7 objects. This has a few benefits:

1. It keeps you away from Curl syntax, which is complicated when you're doing more than just downloading a file
2. If you're proxying, this requires less code as PSR-7 ServerRequest is compliant with PSR-7 Request - in other words, a modified version of your `$request` would usually work fine.
3. Sending the response back is simpler
4. Streaming responses is significantly more straightwarward

Usage
=====

[](#usage)

```
    $handler = new \CurlPsr\Handler();
    $response = $handler->run(
        $request->withUri(
            $request->getUri()
                ->withPath("/")
                ->withHost("example.org")
                ->withScheme("http")
                ->withPort(80)
        ),
        true,
        10000
    );

```

The primary aim of this is to make JSON API proxies simpler.

Limitations
===========

[](#limitations)

This does not attempt to support every possible Curl feature nor everything that can be expressed in PSR-7 requests/responses. Key functionality that should always work includes:

- HEAD requests with properly retained headers
- GET requests to JSON endpoints which may or may not stream
- JSON-RPC request and response passthrough via POST
- DELETE requests
- OPTIONS requests
- PUT requests for short JSON resources

Advanced Usage
==============

[](#advanced-usage)

If you want to do two or more requests in parallel, you can. To do this, you use:

```
    $handler = new \CurlPsr\Handler();
    $responses = $handler->withTimeout(10000)->runSimple(
        $request1,
        $request2
    );
    foreach($responses as $k => $response) {
        if($response->getBody()->getSize()) {
            echo "" . $response->getUri();
            echo "" . $response->getBody();
        }
    }

```

The return to `runSimple()` is in fact an iterator which will run over the same objects multiple times: once for the headers, once or more for body chunks, and once more when the transfer is known to be complete. The body attached to the response will always be up-to-date with the latest packet, but won't report a size until it's done.

If you want specific keys to make it easier to tell which response is which, you can use `runMap()`:

```
    $handler = new \CurlPsr\Handler();
    $responses = $handler->withTimeout(10000)->runMap([
        "a" => $request1,
        "b" => $request2
    ]);
    foreach($responses as $k => $response) {
        if($response->getBody()->getSize()) {
            echo "" . $response->getUri();
            echo "" . $response->getBody();
        }
    }

```

###  Health Score

47

—

FairBetter than 93% of packages

Maintenance73

Regular maintenance activity

Popularity7

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity84

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~244 days

Recently: every ~609 days

Total

11

Last Release

151d ago

Major Versions

v0.9.4 → v1.0.02019-05-25

v1.1.3 → v2.0.02026-01-30

PHP version history (2 changes)v0.9.0PHP ^7.1

v2.0.0PHP ^8.5

### Community

Maintainers

![](https://www.gravatar.com/avatar/6c5599e11c6d7b39086d53133c1ee1420f39c9f29b012a02aedbc11138f4d8d1?d=identicon)[jj101k](/maintainers/jj101k)

---

Top Contributors

[![jj101k](https://avatars.githubusercontent.com/u/444556?v=4)](https://github.com/jj101k "jj101k (50 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/jdriscoll-curl-psr/health.svg)

```
[![Health](https://phpackages.com/badges/jdriscoll-curl-psr/health.svg)](https://phpackages.com/packages/jdriscoll-curl-psr)
```

###  Alternatives

[php-http/cache-plugin

PSR-6 Cache plugin for HTTPlug

25025.5M80](/packages/php-http-cache-plugin)[illuminate/http

The Illuminate Http package.

11937.2M6.6k](/packages/illuminate-http)[rdkafka/rdkafka

A PHP extension for Kafka

2.2k20.0k1](/packages/rdkafka-rdkafka)[httpsoft/http-message

Strict and fast implementation of PSR-7 and PSR-17

87930.4k113](/packages/httpsoft-http-message)[mezzio/mezzio-router

Router subcomponent for Mezzio

265.3M84](/packages/mezzio-mezzio-router)[serpapi/google-search-results-php

Get Google, Bing, Baidu, Ebay, Yahoo, Yandex, Home depot, Naver, Apple, Duckduckgo, Youtube search results via SerpApi.com

69122.6k](/packages/serpapi-google-search-results-php)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
