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

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

phico/http-client
=================

Simple wrapper around the built in cURL functions built for Phico

08PHP

Since Aug 4Pushed 1y agoCompare

[ Source](https://github.com/phico-php/http-client)[ Packagist](https://packagist.org/packages/phico/http-client)[ RSS](/packages/phico-http-client/feed)WikiDiscussions main Synced yesterday

READMEChangelogDependenciesVersions (1)Used By (0)

Http Client
===========

[](#http-client)

A simple http client wrapping the built in cURL functions.

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

[](#installation)

Install via composer

```
composer require phico/http-client
```

Usage
-----

[](#usage)

### Making requests

[](#making-requests)

#### GETing remote content

[](#geting-remote-content)

Use `get()` to request a page, the result is stored in the response `body`.

```
$response = http()->get('https://example.com');
echo $response->body;
```

Send query parameters as the second argument

```
$response = http()->get('https://example.com/hello', [
    'cache' => false,
    'name' => 'Bob'
]);
echo $response->body;
```

All http methods are supported

- GET
- POST
- DELETE
- PUT
- PATCH
- HEAD
- OPTIONS

Custom verbs can be used via `method()`

```
$response = http()->method('PURGE', 'https://example.com/cache');
```

#### POSTing Form data

[](#posting-form-data)

```
$response = http()
    ->form([
        'user' => 'bob',
        'password' => 't0p-secret'
    ])->post('https://example.com/signin');
```

##### With a file

[](#with-a-file)

```
$response = http()
    ->form([
        'overwrite' => true,
    ])
    ->file('/path/to/file')
    ->post('https://example.com/upload');
```

File also accepts an optional filename and optional mime-type.

```
$response = http()
    ->file('/path/to/invoice.pdf', 'invoice-2024.pdf')
    ->file('/path/to/readme.txt', 'read-me.txt', 'text/plain')
    ->post('https://example.com/upload');
```

#### POSTing JSON data

[](#posting-json-data)

```
$response = http()
    ->json([
        'colour' => 'Blue'
    ])
    ->put('https://example.com/widgets/123');
```

### Responses

[](#responses)

Every request returns a structured response containing the request made, the response cookies, headers, status code and body.

```
$response = http()
    ->json([
        'colour' => 'Blue'
    ])
    ->post('https://example.com/widgets/123');

echo $response->http_code; // 200, 401, 500 etc..
echo $response->body;
echo join("\n", $response->cookies);  // cookies array
echo join("\n", $response->headers); // headers array

// and weirdly
var_dump($response->request);
```

### Error handling

[](#error-handling)

Exceptions will be thrown on connection or transport errors only, your code should handle the http status codes appropriately.

```
try {
    $response = http()
        ->form([
            'user' => '',
            'password' => 't0p-secret'
        ])->post('https://example.com/signin');
} catch (HttpClientException $e) {

   // show exception details
   echo $e->getSummary();
   echo $e->getTraceAsString();

}
```

###  Health Score

14

—

LowBetter than 1% of packages

Maintenance27

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity18

Early-stage or recently created project

 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.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/65541311?v=4)[indgy](/maintainers/indgy)[@indgy](https://github.com/indgy)

---

Top Contributors

[![indgy](https://avatars.githubusercontent.com/u/65541311?v=4)](https://github.com/indgy "indgy (12 commits)")

### Embed Badge

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

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

###  Alternatives

[php-http/cache-plugin

PSR-6 Cache plugin for HTTPlug

25126.1M82](/packages/php-http-cache-plugin)[illuminate/http

The Illuminate Http package.

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

A PHP extension for Kafka

2.2k24.3k1](/packages/rdkafka-rdkafka)[httpsoft/http-message

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

87965.9k114](/packages/httpsoft-http-message)[mezzio/mezzio-router

Router subcomponent for Mezzio

265.4M91](/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

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

PHPackages © 2026

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