PHPackages                             adampatterson/http - 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. adampatterson/http

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

adampatterson/http
==================

A simple Guzzle wrapper

1.5.0(2mo ago)110[2 PRs](https://github.com/adampatterson/Http/pulls)1MITPHPCI passing

Since Apr 3Pushed 6d ago1 watchersCompare

[ Source](https://github.com/adampatterson/Http)[ Packagist](https://packagist.org/packages/adampatterson/http)[ RSS](/packages/adampatterson-http/feed)WikiDiscussions main Synced today

READMEChangelog (6)Dependencies (9)Versions (11)Used By (1)

HTTP PHP
========

[](#http-php)

[![PHP Composer](https://github.com/adampatterson/http/workflows/run-tests/badge.svg?branch=main)](https://github.com/adampatterson/http/workflows/run-tests/badge.svg?branch=main)[![Packagist Version](https://camo.githubusercontent.com/4e81504c256a387649b69352c5f1b5eca143207ad466d94bd80095b0bf72b7a0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6164616d706174746572736f6e2f68747470)](https://packagist.org/packages/adampatterson/http)[![Packagist Downloads](https://camo.githubusercontent.com/eaf0c3d29cc8aa650a2fc5e786ee5314f483389720441b3deae29009231b8f05/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6164616d706174746572736f6e2f68747470)](https://packagist.org/packages/adampatterson/http/stats)

Note

This script is still under development.

Install from [Packagist](https://packagist.org/packages/adampatterson/http)
---------------------------------------------------------------------------

[](#install-from-packagist)

```
composer require adampatterson/http
```

Usage
-----

[](#usage)

### Basic Usage

[](#basic-usage)

```
use Http\Http;
use GuzzleHttp\Cookie\CookieJar;

// GET request
$response = Http::get('https://example.com/api/users');

// POST request with JSON
$response = Http::asJson()->post('https://example.com/api/users', ['name' => 'John']);

// POST request with form parameters
$response = Http::asFormParams()->post('https://example.com/api/users', ['name' => 'John']);

// Request with custom headers
$response = Http::withHeaders(['X-Custom' => 'value'])->get('https://example.com/api/users');

// Request with Bearer token
$response = Http::withToken('your-token')->get('https://example.com/api/users');

// Request with simple cookie array (domain required for direct array conversion)
$response = Http::withCookies(['session_id' => 'abc123'], 'example.com')
    ->get('https://example.com/api/users');

// Request with a reusable Guzzle cookie jar
$jar = CookieJar::fromArray(['session_id' => 'abc123'], 'example.com');
$response = Http::withCookieJar($jar)->get('https://example.com/api/users');
```

### Response Helpers

[](#response-helpers)

The `HttpResponse` object provides several helpers to inspect the response:

```
use Http\Http;

// GET request
$response = Http::get('https://example.com/api/users');

$response->status();  // Get status code (int)
$response->body();    // Get raw body (string)
$response->array();   // Get JSON decoded body (array)
$response->object();  // Get JSON decoded body (object)
$response->collect(); // Get JSON decoded body (Collection)
$response->header('Content-Type'); // Get specific header
$response->headers(); // Get all headers

$response->isSuccess();     // 200-299
$response->isOk();          // Alias for isSuccess
$response->isRedirect();    // 300-399
$response->isClientError(); // 400-499
$response->isServerError(); // 500+
```

### Method Proxying

[](#method-proxying)

If you need to access a method on the underlying Guzzle response that is not explicitly defined in `HttpResponse`, it will be automatically proxied:

```
// getProtocolVersion() is not defined in HttpResponse,
// so it is proxied to GuzzleHttp\Psr7\Response
$version = $response->getProtocolVersion();
```

### Request/Response Flow

[](#requestresponse-flow)

At a high level, the package separates request building from response consumption:

1. The `Http` facade forwards static calls to `MakeHttpRequest`.
2. `MakeHttpRequest` collects fluent configuration (`asJson`, `withHeaders`, `withToken`, `withCookies`, etc.) and verb payload options.
3. `send()` merges options, parses query params from the URL, executes the Guzzle request, and captures transfer stats.
4. The raw PSR-7 response is wrapped in `HttpResponse`.
5. `HttpResponse` exposes helper methods (`body`, `json`, `status`, etc.) and proxies unknown methods to Guzzle.

This flow keeps transport concerns in `MakeHttpRequest` and read helpers in `HttpResponse`.

Tests
-----

[](#tests)

```
composer install
composer test
```

### Code Coverage

[](#code-coverage)

To run tests with code coverage, ensure you have Xdebug installed and run:

```
composer test-coverage
```

Local Dev
---------

[](#local-dev)

Without needing to modify the `composer.json` file. Run from the theme root, this will symlink the package into the theme's vendor directory.

```
ln -s ~/Sites/packages/http/ ./vendor/adampatterson/http
```

Otherwise, you can add the local package to your `composer.json` file.

```
{
  "repositories": [
    {
      "type": "path",
      "url": "/Sites/packages/http"
    }
  ]
}
```

###  Health Score

45

—

FairBetter than 91% of packages

Maintenance93

Actively maintained with recent releases

Popularity7

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 97.3% 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 ~370 days

Recently: every ~462 days

Total

6

Last Release

66d ago

Major Versions

0.0.4 → 1.0.02026-04-25

### Community

Maintainers

![](https://www.gravatar.com/avatar/042770de9c0c4d404547538b5a64dfe6f6e4400e212e6db042b541e3bef250c4?d=identicon)[adampatterson](/maintainers/adampatterson)

---

Top Contributors

[![adampatterson](https://avatars.githubusercontent.com/u/31537?v=4)](https://github.com/adampatterson "adampatterson (73 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (2 commits)")

---

Tags

httpGuzzle

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/adampatterson-http/health.svg)

```
[![Health](https://phpackages.com/badges/adampatterson-http/health.svg)](https://phpackages.com/packages/adampatterson-http)
```

###  Alternatives

[craftcms/cms

Craft CMS

3.6k3.6M3.1k](/packages/craftcms-cms)[illuminate/http

The Illuminate Http package.

11937.9M6.9k](/packages/illuminate-http)[kitetail/zttp

A developer-experience focused HTTP client, optimized for most common use cases.

1.7k1.2M72](/packages/kitetail-zttp)[graham-campbell/guzzle-factory

Provides A Simple Guzzle Factory With Good Defaults

927.0M55](/packages/graham-campbell-guzzle-factory)[eljam/guzzle-jwt-middleware

A jwt authentication middleware for guzzle 6

28761.5k3](/packages/eljam-guzzle-jwt-middleware)[whatsdiff/whatsdiff

See what's changed in your project's dependencies

771.2k](/packages/whatsdiff-whatsdiff)

PHPackages © 2026

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