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

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

abollinger/http
===============

A library to perform HTTP requests using curl.

v2.0.2(2mo ago)0124MITPHP

Since Dec 2Pushed 2mo agoCompare

[ Source](https://github.com/Antoine-Bollinger/http)[ Packagist](https://packagist.org/packages/abollinger/http)[ RSS](/packages/abollinger-http/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (8)Dependencies (2)Versions (9)Used By (0)

Abollinger\\Http\\Client
========================

[](#abollingerhttpclient)

**Abollinger\\Http\\Client** is a lightweight, static PHP HTTP client for making GET, POST, PUT, and DELETE requests. It simplifies HTTP interactions with support for custom headers, data payloads, and response parsing (including headers and body).

---

Features
--------

[](#features)

- **Static Methods**: Easy-to-use static methods for common HTTP verbs (`get`, `post`, `put`, `delete`).
- **Header Support**: Custom headers for requests and parsed response headers.
- **JSON Parsing**: Automatic JSON decoding for response bodies, with fallback to raw output.
- **Error Handling**: Clear error messages and HTTP status code validation.
- **cURL-Based**: Uses PHP’s cURL for reliable and flexible HTTP communication.

---

Requirements
------------

[](#requirements)

- PHP 7.4 or higher
- cURL extension enabled
- Composer autoloading

---

Installation
------------

[](#installation)

Include the class via Composer autoloading. Install the Abollinger\\Http package using composer. Run the following command:

```
composer require abollinger/http
```

Then, load the class in your code:

```
require_once 'vendor/autoload.php';

use Abollinger\Http\Client;
```

---

Usage
-----

[](#usage)

### Making a GET Request

[](#making-a-get-request)

```
$response = Client::get([
    'url' => 'https://api.example.com/data',
    'headers' => ['Authorization' => 'Bearer token123']
]);
```

### Making a POST Request

[](#making-a-post-request)

```
$response = Client::post([
    'url' => 'https://api.example.com/data',
    'data' => ['key' => 'value'],
    'headers' => ['Content-Type' => 'application/json']
]);
```

### Retrieving Headers Only

[](#retrieving-headers-only)

```
$headers = Client::getHeaders([
    'url' => 'https://api.example.com/data'
]);
```

You can use this method to obtain normalized headers (example: "content type" becomes "Content-Type"):

```
$headers = Client::getNormalizedHeaders([
    'url' => 'https://api.example.com/data'
]);
```

### Handling the Response

[](#handling-the-response)

The response is always an associative array with the following structure:

```
[
    'status' => 200, // HTTP status code
    'headers' => ['Content-Type' => 'application/json', ...], // Parsed headers
    'body' => ['data' => '...'] // Parsed body (or ['raw' => '...'] if not JSON)
]
```

### Error Handling

[](#error-handling)

If the request fails, the response will include an `error` key:

```
if (isset($response['error'])) {
    echo "Error: " . $response['error'];
}
```

---

API Reference
-------------

[](#api-reference)

### Static Methods

[](#static-methods)

#### `get(array $params = []): array`

[](#getarray-params---array)

Performs a GET request. Returns the parsed response body.

#### `getHeaders(array $params = []): array`

[](#getheadersarray-params---array)

Performs a GET request. Returns the parsed response headers.

#### `getNormalizedHeaders(array $params = []): array`

[](#getnormalizedheadersarray-params---array)

Performs a GET request. Normalize and returns the parsed response headers.

#### `post(array $params = []): array`

[](#postarray-params---array)

Performs a POST request. Returns the parsed response body.

#### `put(array $params = []): array`

[](#putarray-params---array)

Performs a PUT request. Returns the parsed response body.

#### `delete(array $params = []): array`

[](#deletearray-params---array)

Performs a DELETE request. Returns the parsed response body.

---

### Parameters

[](#parameters)

All methods accept an associative array of parameters:

KeyTypeDescription`url`string**Required.** The target URL.`method`stringHTTP method (GET, POST, PUT, DELETE). Default: `GET`.`data`arrayRequest payload. Automatically URL-encoded for GET, or sent as-is for POST/PUT.`headers`arrayCustom headers. Default: `['Content-Type: application/x-www-form-urlencoded']`.---

Example Workflow
----------------

[](#example-workflow)

```
use Abollinger\Http\Client;

// GET request
$data = Client::get(['url' => 'https://api.example.com/users']);

// POST request with custom headers
$result = Client::post([
    'url' => 'https://api.example.com/users',
    'data' => ['name' => 'John Doe'],
    'headers' => ['Authorization' => 'Bearer token123']
]);
```

---

License
-------

[](#license)

This library is licensed under the MIT License. For full license details, see the `LICENSE` file distributed with this source code.

---

Author
------

[](#author)

Antoine Bollinger Email:

For contributions, issues, or feedback, feel free to reach out or open an issue on the relevant repository.

###  Health Score

39

—

LowBetter than 86% of packages

Maintenance87

Actively maintained with recent releases

Popularity12

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity44

Maturing project, gaining track record

 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 ~66 days

Recently: every ~74 days

Total

8

Last Release

66d ago

Major Versions

v1.0.4 → v2.0.02026-03-12

### Community

Maintainers

![](https://www.gravatar.com/avatar/4ef76077f29bfc3b32b0b1d21d2f4122af8109f23aa48586ea68d768e01f354f?d=identicon)[antoinebollinger](/maintainers/antoinebollinger)

---

Top Contributors

[![antoinebollinger](https://avatars.githubusercontent.com/u/56133015?v=4)](https://github.com/antoinebollinger "antoinebollinger (10 commits)")

### Embed Badge

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

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

###  Alternatives

[friendsofsymfony/rest-bundle

This Bundle provides various tools to rapidly develop RESTful API's with Symfony

2.8k73.3M319](/packages/friendsofsymfony-rest-bundle)[php-http/discovery

Finds and installs PSR-7, PSR-17, PSR-18 and HTTPlug implementations

1.3k309.5M1.2k](/packages/php-http-discovery)[nyholm/psr7

A fast PHP7 implementation of PSR-7

1.3k235.4M2.4k](/packages/nyholm-psr7)[pusher/pusher-php-server

Library for interacting with the Pusher REST API

1.5k94.8M293](/packages/pusher-pusher-php-server)[spatie/crawler

Crawl all internal links found on a website

2.8k16.3M52](/packages/spatie-crawler)[react/http

Event-driven, streaming HTTP client and server implementation for ReactPHP

78126.4M414](/packages/react-http)

PHPackages © 2026

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