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 1mo ago

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 2% of packages

Maintenance28

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity17

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

[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)
